Django Module
One installation:
PIP3 Install Django
Or
python-m pip Install Django
Two Add environment variables
Related commands:
1 # cmd under 2 3 django-admin startproject name# folder name 45 python manage.py Runserver 127.0.0.1:8000# boot
Django creates the project catalog feature
Name
-name #整个程序进行配置目录
--init
--settings #配置文件
--urls #usr对应关系
--wsgi #WSIG规范 (Uwsgi+nginx)
--manage.py #管理Django程序
Related commands:
Python manage.py makemigrations #操作数据库
Python manage.py Migrate
App Catalog
-migrations Data Manipulation record (modify table structure)
--apps #配置当前的app
--models #创建数据库表结构 (ORM writes a specified class, creates a table from a command)
--tests #单元测试
--views #业务代码
Django Base Usage
A path to the configuration template (the new Django default has it)
--settings #配置文件
' DIRS ': [Os.path.join (Base_dir, ' templates ')],
Two configuration static file paths
Create directory static
Statcfiles_dirs= (
Os.path.join (Base_dir, ' static '
)
Django Template language
1 {% for row in user_list%}2 <TR>3 <TD>{{Row.username}}</TD>4 <TD>{{Row.email}}</TD>5 <TD>{{Row.sex}}</TD>6 7 </TR>8{% ENDFOR%}
Django Request Cycle
Python 96th Day---Django (1)