1. Web Framework
Mvc
Model View Controller
Database template file Business processing
Mtv
Model Template View
Database template file Business processing
############## Web:mvc, MTV
2. Django
PIP3 Install Django
C:\Python35\Scripts
# Create a Django project
Django-admin startproject "project name"
MySite
-MySite # To configure the entire program
-Init
-Settings # configuration file
-URL # URL correspondence relationship
-Wsgi # Follow Wsig specification, Uwsgi + nginx
-manage.py # Managing Django Programs:
-Python manage.py
-Python manage.py Startapp xx
-Python manage.py makemigrations
-Python manage.py Migrate
# Run the Django feature
Python manage.py runserver 127.0.0.1:8001
Chouti
-Chouti
-Configuration
-Main Station app
-Manage apps in the background
# Create App
Python manage.py Startapp CMDB
Python manage.py Startapp OpenStack
Python manage.py startapp xxoo ....
App
Migrations Data modification Table structure
Admin Django provides us with background management
Apps Configure the current app
Models ORM, writes the specified class by command to create a database structure
Tests Unit Test
Views business code
1. Path to the configuration template
TEMPLATES = [
{
' Backend ': ' Django.template.backends.django.DjangoTemplates ',
' DIRS ': [Os.path.join (Base_dir, ' templates ')],
' App_dirs ': True,
' OPTIONS ': {
' Context_processors ': [
' Django.template.context_processors.debug ',
' Django.template.context_processors.request ',
' Django.contrib.auth.context_processors.auth ',
' Django.contrib.messages.context_processors.messages ',
],
},
},
]
2. Configure the static directory
Static
Staticfiles_dirs = (
Os.path.join (Base_dir, ' static '),
)
<link rel= "stylesheet" href= "/static/commons.css"/>
Python Learning Path 8