Implementing MTV model in Python Django

Implementing MTV model in Python Django

Python is a programming language which can be used for different tasks like program scripting, database programming, etc. On the other hand, Django is a web framework used to build website with numerous webpages, coded in Python.

Web framework is the framework for creating webpages. Each framework follows an M-V-C architecture pattern for building website to separate the data with business rules from the user interface. In Django web development, MVC is renamed as MTV. MTV is similar to MVC, but the difference lies in their recognition. In Django, MTV pattern stands

MVC Vs MTV

for Model, T stands for Template, and V stands for views. Roles of each component is the same as in MVC, just with different names. Specifically, Model manages the data, Template is about the representations of the data and View is all about the logic to be processed on data.

Specifically, Django’s Model is the data access layer containing everything about data. Django’s Template is the presentation layer containing all presentation related decisions. And, Django’s View is the business logic layer containing logic that access the model and refers to the appropriate template.

Django Template

Concluding the whole concept, we can say, in MTV, a request to a URL is dispatched to a view. This view calls into the Model, performs the manipulation and prepares the data for output. The data is passed to a Template that is rendered and emitted as a response.

 

Author

2 Comments
  1. Nicely explained!

    Cant find any contact information, so I’ll try here: Can I use that MTV overview picture in my bachelors report for a Django website?

    Thanks

Leave a Reply