DEV Community

Priyanshu Panwar
Priyanshu Panwar

Posted on

Everything About Django - 2 (Architecture of Django)

This is the second blog of my series Everything About Django. You can read my previous article here.
In this article, we are going to learn the core architecture of Django, how Django works.

Architecture of Django

Django follows the architecture MVT - Model View Template.
Let's break the MVT architecture :

  • Model : This is the database layer of the architecture. Model means the tables stored in the database. Django follows the ORM (Object Relational Mapping) Protocol by which we can write the database commands in pythonic way without any SQL. We will study this in detail in coming blog.
  • View : This is the logical layer of the architecture. This is where we write the logic of our project. We create functions/classes which are mapped to different URL Patterns of our site (project).
  • Template : This is the display layer of the architecture. This contains the html files that are rendered(displayed) on our web interface. Every view(function/class) sends a template or a http response.

Let's take a look at this picture for clear understanding.
MVT Pattern
Let's drop this into few points:

  • A user opens a specific url of our site (project) suppose http://localhost:8000/login
  • Django maps this url to the specific view (function) which implements the logic for this url.
  • The view takes the data from associated models (database) and sends a template which is rendered on the web interface.

I hope the MVT architecture of Django is clear. Feel free to comment your doubts.

THANK YOU

You can find me at : My Portfolio | LinkedIn

Top comments (2)

Collapse
 
thumbone profile image
Bernd Wechner

Just a quick tip. You can put these two articles in a series, and that way each one will at top have a table of contents containing both. To do that just edit the article and at the bottom of the page you should see the Series feature. As you add more posts to your tutorials they can all form part of a growing series.

Collapse
 
priyanshupanwar profile image
Priyanshu Panwar

Thanks a ton bruh for this. I didnt know about it. I ll doit.