MVC model and MTV model, MVC model MTV Model
MVC model:
MVC (Model View Controller Model-View-Controller) is a Web architecture Model that separates business logic, Model data, and user interfaces, allowing developers to decouple data and performance, front-end engineers can only change the page effect without accessing the back-end code. DBA can rename the data table and only change one place without searching and replacing a large number of files.
MVC divides web applications into three layers: models, views, and controllers. Loosely Coupled connection method, similar to plug-ins. This improves the code reuse capability.
MVC features unidirectional:
1. the browser sends a request
2. The controller interacts with the model to obtain data.
3. Controller call View
4. view rendering data and return
MTV model:
Unlike the Web frameworks in Rails, Spring, Laravel, and other languages, in Python, basically the MVC variant MTV (Model Templates View Model-template-View) is used)
Taking django's MTV as an example, MTV represents models, templates, and views respectively.
1. Model: like the MVC Model, it processes all data-related transactions: how to access, how to confirm validity, What behaviors are included, and the relationship between data.
2. Template: process performance-related decisions and display them on pages or other types of documents.
3. View: process the business logic. View is a callback function of a specific URL, which describes the data. Extract the corresponding data from the Model and call the relevant template. It is the communication function to be called by contorroller to implement control between the Model and View.
[Note] the objective of MVC and MTV is different:
The purpose of View in MVC is to present the data.
The purpose of MTV View is to display data.