Let’s talk about MVT Architecture in Django

KC Mahendra

KC Mahendra

15 April 2023 - 3 min read

Django web framework has a model-view-template (MVT) architecture, which makes it the only framework you’ll need to create a complete website or web application. This Python framework allows you to create models that generate databases and render dynamic HTML templates to the UI using views.

Workflow of MVT Architecture


The Model manages the data and is represented by a database. A model is basically a database table. The model is responsible for handling all data-related tasks. It can be a table in a database, a JSON file, or anything else. The model takes the data from where it is stored and then processes it before sending it to the view. If the model needs to be changed, it is done in a single place. In a web-based application, the model is the place where data is transformed from one format to another.

The View receives HTTP requests and sends HTTP responses. A view interacts with a model and template to complete a response. The View is the user interface — what you see in your browser when you render a website. It is represented by HTML/CSS/Javascript and Jinja files. A view is used to display the data from the model component. It can also be used to collect data from the user and send it to the Model as a form input. In this way, the View component contains the UI logic.

The Template is basically the front-end layer and the dynamic HTML component of a Django application. A template is nothing but the front-end components of a Django application. It contains the static HTML output of the webpage as well as the dynamic information. To generate HTML dynamically Django uses DTL(Django Template Language) along with static HTML. Using DTL Django is able to show data from models dynamically.

In simple you want to explain MVT Architecture A user searches for a URL pattern that is nothing but a request for a certain web page. After sending the request to the server Django will search for the corresponding view for this request. The view will talk to the model and template to create a complete response for the request. So mainly the MVT structure together creates a response for a corresponding request.

about the author

Full stack developer having 4 years of industrial experience in designing, development and maintenance of web apps based on Django-Python platforms.worked with different types of relational database(RDBMS) like: Sqlite,mysql,oracle