How Django Works?
February 3rd 2020 665
This tutorial is about giving you an idea about how Django internally does the job and serves its purpose. So let's see how Django works and it's MVT architecture.
The Model-View-Controller (MVC) is an architectural pattern that separates an application into three main logical components: the model, the view, and the controller. MVC is one of the most frequently used industry-standard web development framework to create scalable and extensible projects.
Django MVT Pattern
Django is based on MVT (Model-View-Template) architecture. MVT is a software design pattern for developing a web application. It is a collection of three important components:
- Model: The Model helps to handle database
- View: View is used to execute the business logic and interact with a model to carry data and renders a template i.e it is the actual backend code.
- Template: The template is a presentation layer which handles User Interface part completely i.e HTML pages
Although Django follows MVC pattern but maintains it's own conventions. So, control is handled by the framework itself. There is no separate controller and complete application is based on Model View and Template. That's why it is called MVT application.
So here, a user requests for a resource to the Django, Django works as a controller and check to the available resource in URL (urls.py file). If URL maps, a view (function) is called that interact with model and template, it renders a template. Django responds back to the user and sends a template as a response.