Django follows a MVC- MVT architecture.

MVC stands for Model View Controller. It is used for developing the web publications, where we break the code into various segments. Here we have 3 segments, model view and a controller.

mvc - Django Tutorial - Edureka

Model –  Model is used for storing and maintaining your data. It is the backend where your database is defined.

Views – In Django templates, views are in html. View is all about the presentation and it is not at all aware of the backend. Whatever the user is seeing, it is referred to a view.

Controller – Controller is a business logic which will interact with the model and the view.

Now that we have understood MVC, lets learn about Django MVT pattern.

MVT stands for Model View Template. In MVT, there is a predefined template for user interface. Let’s take an example, say you want to write several static html forms like hello user 1, hello user2 and so on. With template, you will be having only one file that prints hello along with the variable name. Now this variable will be substituted in that particular template using some jinja logic. That’s the magic of template, you don’t need to rewrite the code again n again!

Now you might be wondering where is the controller?

In the case of MVT, Django itself takes care of the controller part, it’s inbuilt.

Moving ahead in Django tutorial, let’s understand how things work internally.

In the above image, template is your front end which will interact with the view and the model will be used as a backend. Then view will access both the model and the templates and maps it to a url. After that, Django plays the role of controller and serves it to the user.

Now that you understand the architecture or how Django works internally, let’s move ahead in Django tutorial and install Django in our systems.

Is Django frontend or backend?

  • Neither, Django is a framework, Python is the language in which Django is written.
  • For the front end, Django helps you with data selection, formatting, and display. It features URL management, a templating language, authentication mechanisms.
  • For the backend, Django comes with an ORM that lets you manipulate your data source with ease, forms to process user input and validate data and signals, and an implementation of the observer pattern.

Leave a Reply

Your email address will not be published.