MTV architecture
Django implements the MTV architecture to sperate the presentation, business and database layers to improve the code readability and maintainability.
what is MVC architecture?¶
- MVC - Model View Controller
- It is a pattern in software design commonly used to implement user interfaces, data, and controlling logic.
- It emphasizes a separation between the software's business logic and display.
- This "separation of concerns" provides for a better division of labor and improved maintenance.
parts of the MVC¶
- Model: Manages data and business logic.
- View: Handles layout and display.
- Controller: Routes commands to the model and view parts.
Model¶
- The model component stores data and its related logic.
- It represents data that is being transferred between controller components or any other related business logic.
- It manipulates data and sends back to the database or uses it to render the same data.
- Example: Database queries, core app logic
View¶
- A View is that part of the application that represents the presentation of data.
- Views are created by the data collected from the model data.
- A view requests the model to give information so that it presents the output presentation to the user.
- The view also represents the data from charts, diagrams, and tables.
- Example: HTML rendering based on the model data
Controller¶
- The Controller is that part of the application that handles the user interaction.
- Example: Routing the urls, processing request
Django - MTV¶
- Django also follows the MVC pattern but it just used different terminology.
- M - Model
- T - Template (i.e View)
- V - View (i.e Controller)