程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

2022 Summer Practice (Django Tutorial Learning Record) (5th week 4) P58 content review and knowledge sorting

編輯:Python

P58 Content Review and Knowledge Sorting

1. Install Django
pip install django

2. Create a Django project
django-admin startproject mysite
can be created with cmd window,
can also be created with Pycharm,
create with Pycharm to delete the DIR templates in the setting

3. Create app and register
python manage.py startapp app01
python manage.py startapp app02

setting.pyINSTALLED_APPS = {...."app01.apps.App01Config",}Find html files in order of App registrationOnly after the App is registered can the table be created in the database

4. Configure the static file path and template path (put it in the app directory)
5. Configure the database related operations:
Third-party module (django3)
pip install mysqlclient
FirstTo create a database (use the command to create, modify the character to utf-8, otherwise an error will be reported)
Write the class of the table in models.py
Generate the table in models.py
python manage.pymakemigration
python manage.py migrate
You can also use Django's default file database sqlite3 (usually used for development, less online)
Pycharm needs to be configured to open this file
6. Set the correspondence between URL and function in url.py

7. Write business logic in views.py view function

8. Write HTML templates in the templates directory (template syntax, inheritance)

9.ModelForm and Form components, adding, deleting, modifying and checking functions
Generate HTML tags, (generate default input box)
Data verification (valid)
Save to database (ModelForm)
Get errorsInformation

10.Cookie and session, save user login information

11. Implement user authentication based on middleware, without writing each view function

12.ORM operation
models.User.objects.filter(id="xx")
models.User.objects.filter(id="xxx").order_by("-id")

13. Paging component

14. Verification code

15.Ajax request

16. For more information, you can use the paging component


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved