Django MVT Structure

Posted By :Vikas Verma |27th September 2019

It's a variation of the MVC pattern it's acronym itself the "Template" keyword replaces the Controller. The Template is not exactly functioning as the controller and have some different properties as that of the controller.

 

It's based on MVT (Model-View-Template) architecture. Model-View-Template is a software design pattern to develop a web application.

 

The framework uses a famous tag line: The web framework for perfectionists with deadlines.

 

MVT has the following 3 parts

 

M — — — — >Models. — — — ->For Database Code
V — — — — >Views. — — — — >For Business Logic
T — — — — >Templates. — — ->For Design Part

 

Models: It represents how data is organized in the database. In other words, in MVC pattern we use models to define our database tables as well as the relationships between them.

 

Views: A view is what you see when you visit a site. For example, a landing page, a modal, etc are examples of views. A View contains information that will be eventually sent to the client i.e browser. Generally, views are HTML documents.

 

Template: It is consists of static parts of the desired HTML output as well as some special syntax describing how dynamic content will be inserted.

 

Project Structure :

The Project when initialized it contains basic files by default such as manage.py, view.py, etc. A simple project structure is enough to create a basic or single page application. Here are the major files and their explanations. Inside the project folder, these are the following files-

 


Credit: geeksforgeeks

 

manage.py- File is used to interact with the project via the command line(start the server, sync the database… etc). To full list of command that can be executed by manage.py type this code in the command window-

 

$ python manage.py help

 

_init_.py : It is a python package.


settings.py : As the name indicates it contains all the necessary settings for the website. In this file, we register any applications we set the routes of static files, database configuration details, and other useful configuration-related settings.


urls.py : The file which stores all links of the project and functions to call.


wsgi.py : File is used in deploying the project in WSGI. It also helped 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


About Author

Vikas Verma

He is frontend developer. He is a learner by heart and has a passion and profile to adapt various technologies.

Request For Proposal

[contact-form-7 404 "Not Found"]

Ready to innovate ? Let's get in touch

Chat With Us