DEV Community

Cover image for Django MVT Architecture
JSXJunkie
JSXJunkie

Posted on

Django MVT Architecture

Django follows MTV design pattern (Model -> View -> Templates) MTV architecture is backbone of Django Development.

  • Model : The data you want to present, usually data from a database.
  • View : A request handler that return the relevant template and content-based on the request from the user.
  • Templates : A text file(Like an HTML file -Django HTML_ ) containing the layout of the web page, with logic on how the display the data.

Model modelps.py
The model provides data from the databases.

  • In django, the data is delivered as an Object Relational Mapping(ORM), which is a technique designed to make it easier to work with databases.
  • The most common way to extrct data from a databased is SQL. One problem with SQl is complex and need pretty good understanding on SQL statements. But Django with ORM make it easier to comminicate with the database without having to write complex SQL statement.

View views.py
A view is a function or method that taked http requests as arguments, imports the relevant models and finds out what data to send to the template, and returns the final result.

Templtes
A templates is a file where you describe how the result should be represented.

  • Templates are often .html files, with HTML code describing the layout of a web page, but it can also be in other file formats to present other results, but we will concentrated on .html files.

Top comments (0)