QamoosTech
Architecture & DesignPatternsBeginnerDjangoPython

MTV (Model-Template-View)

PronunciationEM-TEE-VEE

Definition

MTV is Django's way of organising an app into three parts: the Model (data and database), the Template (the HTML shown to the user) and the View (the logic that connects them). It matches MVC, with Django's View acting as the controller.

Where you hear it

In Django tutorials, interview questions ("how is MTV different from MVC?"), and architecture diagrams.

Examples

  • In MTV the model holds data, the template shows it, the view decides what to show.
  • Django's views are what other frameworks call controllers.
  • In the Django view we fetch the invoices and pass them to the template to render.

Common mistake

Assuming Django's View equals MVC's View. In Django the template is the display part and the view is the logic.

Don't confuse with

MVC, the older pattern with the same three roles under different names.

Say it at work

  • In a meeting or chatExplain MTV in one sentence.
  • In an email or ticketWhere does this code go in MTV?