MVC and MTV ModelMVC model
MVC, a software architecture model in software engineering, divides software systems into three basic parts: model, view, and controller.
They are connected together in a plug-in, loosely coupled way. It has the advantage of low coupling, high reusability and low life cycle cost.
Model: Responsible for mapping the business object to the database (ORM)
View: Responsible for interacting with the user
Control: Accept user input call model and view to complete user's request
MTV Model:
The design pattern of the Django framework draws on the idea of the MVC framework and is divided into three parts to reduce the coupling between the various parts.
The MTV framework is a Django framework with three parts: Model, template, and view
Model: Object that is responsible for business objects and databases (ORM)
Template (Template): Responsible for how to display the page to the user
View: Responsible for business logic, and call model and template when appropriate
In addition, Django also has a URLs distributor,
It does this by distributing page requests for URLs to different view processes, and then calling the corresponding model and template
The correspondence between Django's MTV and the Generalized MVC:
Model----models.py
View----Templates
Controllers (Controller)-----view.py and urls.py
1, download DJANGO:PIP3 install Django2. Create a Django project:
django
-
admin.py startproject mysite
3. Create an app in the MySite directory 4. Start the Django project:
python manage.py runserver
8080
Django allows external access
1. Turn off the firewall
Service Iptables Stop
2. Set up Django
Find allowed_hosts in Settings = []
Modify to allowed_hosts = [' * ',], and be careful not to miss out ","
3. Enter the computer IP and port number of the startup Diango project on the other machine to access the
MTV and MVC models and creating Django projects