MTV and MVC models and creating Django projects

Source: Internet
Author: User

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 mysite3. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.