Main framework components
Django follows the MTV (Model-Template-View) pattern. It is a slightly similar pattern to the well-known MVC (Model-View-Controller) pattern, where the Template acts as View and the framework itself acts as the Controller.
The responsibilities in the Django MTV pattern are divided as follows:
- Model – Defines the logical data structure and is the data handler between the database and the View.
- Template – Is the presentation layer. Django uses a plain-text template system that keeps everything that the browser renders.
- View – Communicates with the database via the Model and transfers the data to the Template for viewing.
The framework itself acts as the Controller. It sends a request to the appropriate view, according to the Django URL configuration.
When developing any Django project, you will always work with models, views, templates, and URLs. In this chapter, you will learn how they fit together.