Overview of Django – MVT (Model View Template) Structure

In this article you’ll learn about Django – MTA Structure.

Model View Template(MVT)

 
Django is based on MVT (Model-View-Template) architecture.
 
MVT is a software design pattern for developing a web application.
  

MVT Structure has three parts

 
1. Model
 
The model is going to act as the interface of your data. It is responsible for maintaining data. It is the logical data structure behind the entire application and is represented by a database (generally relational databases such as MySql, Postgres).
 
2. View
 
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.
3. Template
 
A template consists of static parts of the desired HTML output as well as some special syntax describing how dynamic content will be inserted.
  

Project Structure 

 
A Django Project when initialized contains basic files by default such as
  • manage.py
  • view.py, etc.
A simple project structure is enough to create a single page application.
 
manage.py
 
This file is used to interact with your project via the command line (start the server, sync the database… etc). For getting the full list of commands that can be executed by manage.py type this code in the command window-
 
$ python manage.py help
  1. $ python manage.py help   
  • init_.py - It is python package.
  • settings.py - As the name indicates it contains all the website settings. In this file, we register any applications we create, the location of our static files, database configuration details, etc.
  • urls.py - In this file, we store all links of the project and functions to call.
  • wsgi.py - It is used to help your Django application communicate with the webserver.

Benefits of Django Architecture

  • Rapid Development
  • Loosely Coupled
  • Ease of Modification

Drawbacks of MVC Architecture

  • Too much load on Model Component
  • Development Complexity is high
  • Two components are controlling View

Conclusion

 
That's all. We learned about Model View Template. I hope you understood everything. If you have any doubts, please ask me.
 
Thank you for reading.