MTV development model and example to understand, simple as reading to know, before they are stupid to cry

M refers to the pattern model that is the model, tissue storage data.
T refers to the style is the display format of the content, to use those html / css styles are not automatically generated when you create a project need to manually create the directory
V refers to the views view, we are in the url request to see the contents of the data showed that white url is to deal with ..
Here Insert Picture DescriptionWhen a user sends a URL, the request, wife will url service interface to the server route, this time working views, the views, the processing url, views selection processing method is the corresponding model Models, and styles Templates.
One example of the use to complete a minimum content:
l-> the Python manage.py startApp hello2app
Here Insert Picture Description
create 2-> pycharm the templates directory
Here Insert Picture Description
3-> html file templates are created
Here Insert Picture Description
4-> create content corresponding to views in return

Here Insert Picture Description

5-> New urls file
Here Insert Picture Description
6-> local urls content changes,
Here Insert Picture Description
Here Insert Picture Description
7-> modify the global urls content: mysite is at the urls (not to be confused with the newly created local urls,)
Here Insert Picture Description
8-> modify settings.py content:
Here Insert Picture Description
9-> execute python in cmd manage.py after runserver url displayed in the browser input

Here Insert Picture Description
10-> url browser and enter the directory name http://127.0.0.1:8000/index2/
Here Insert Picture Description
analysis process: 2,3 step operation to complete the operation Templates, which is the template for the operation, that is, we want to page editorial content is displayed.

4 views completed operation function, that is, how to deal with respective url, there is a corresponding html file, i.e. PYC01-HTMLDemo.html

Explain a little add contentHere Insert Picture Description

5,6,7 logic operation is established, create 5 local urls, 6 url specified local area should use hello method found. 7 defines the specified directory and contents corresponding app under global url.
Operation 8 specifies the local directory of dir.
Operation 9 to start the service, open a browser to view the operation 10

Here Insert Picture Description

Guess you like

Origin blog.csdn.net/weixin_43232423/article/details/90451720
Cry