Home  >  Article  >  Backend Development  >  What is Django? A brief introduction to MVC and MVT patterns in Django (pictures and text)

What is Django? A brief introduction to MVC and MVT patterns in Django (pictures and text)

不言
不言Original
2018-09-15 13:57:433995browse

This article brings you what is Django? A brief introduction to Django (pictures and text) has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.


When I was learning Django before, I saw how to use the commands provided by others. I just used them if I didn’t know what they meant. The following is my own learning experience of learning Django. I hope it can help people who want to learn Django but don’t know how to start.

A brief introduction to Django

Features:

1) Weight Level framework

Compared with the Flask framework, Django natively provides numerous functional components to make development easier and faster.

Provide automated script tools for project engineering management

Database ORM support (Object Relational Mapping, English: Object Relational Mapping)

Template

Form

Admin management site

File management

Authentication authority

session mechanism

Cache

2) MVT mode

There is a programming model called MVC. Its core idea is division of labor and decoupling, so as to reduce coupling between different code blocks, enhance code scalability and portability, and achieve backward compatibility.

MVC’s full spelling is Model-View-Controller, which was first proposed by Trygve Reenskaug in 1978. It was invented by Xerox Palo Alto Research Center (Xerox PARC) in the 1980s for the programming language Smalltalk. Software design patterns are designed to apply traditional input, processing, and output tasks to graphical user interaction models. With the emergence of standard input and output devices, developers only need to focus on the analysis and implementation of business logic. It was later recommended as a design pattern for the Java EE platform of Oracle's Sun Company, and is welcomed by more and more developers using ColdFusion and PHP. Although the original division of labor is no longer used, the idea of ​​​​this division of labor is still used and is widely used in software engineering. It is a typical and widely used software architecture model. Later, the idea of ​​MVC was applied to Web development and was called the Web MVC framework.

MVC mode description

##M is spelled out as Model, which mainly encapsulates access to the database layer and adds, deletes, and changes data in the database. Check the operation.

V is spelled out as View, which is used to encapsulate results and generate html content for page display.

C is spelled out as Controller, which is used to receive requests, process business logic, interact with Model and View, and return results.

Django's MVT

M is spelled Model, which has the same function as M in MVC. It is responsible for interacting with the database and performing data processing.

V is spelled out as View, which has the same function as C in MVC. It receives requests, performs business processing, and returns responses.

T is spelled out as Template, which has the same function as V in MVC and is responsible for encapsulating and constructing the HTML to be returned.

Note: The difference lies in the part marked by the black line and black arrow

The above is the detailed content of What is Django? A brief introduction to MVC and MVT patterns in Django (pictures and text). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn