MTV and MVC model

Time:2021-6-9

MVC and MTV Model

1、MVC

MVC is to divide web application into three layers: model (V), controller (c) and view (V); They are connected in a plug-in, loosely coupled way.

  M:models

Object (ORM) responsible for business object and database

  V:views

Responsible for interaction with users (page)

C: Contonnar controller (routing distribution URLs. Py)

Accept the user’s input, call the model and view to complete the user’s request

In essence, MTV is also MVC

 

2、MTV

Django’s MTV pattern is essentially the same as MVC pattern. In order to maintain the loose coupling relationship between components, there are only a few differences in definition. Django’s MTV represents:

  M:models

Object (ORM) responsible for business object and database

  T:templates

Responsible for how to display the page to users

  V:views

Responsible for business logic, and call model and template when appropriate

In addition, Django also has a URL distributor, which is used to distribute the page requests of each URL to different views for processing, and then the view calls the corresponding model and template