MTV Architecture (Django)

MTV (Model-Template-View) is Django's take on the MVC pattern. The Model handles data, the Template handles presentation, and the View holds the logic that ties them together — what other frameworks call the controller.

Django

Django describes itself as an MTV framework, which is essentially MVC with different names. The Model is your data layer (database tables as Python classes). The Template is the HTML with placeholders. The View is a Python function or class that receives a request, talks to models, and renders a template.

The naming confusion is that Django's 'View' is MVC's 'Controller', and Django's 'Template' is MVC's 'View'. The framework itself acts as the controller dispatcher by routing URLs to views. Once you accept the vocabulary, the flow is straightforward: URL → View → Model and/or Template → Response.

Keeping these layers separate is the whole point: business logic lives in views/models, never in templates, and presentation lives in templates, never in views.

Syntax

URL -> View (logic) -> Model (data) + Template (HTML)

Examples

Python

# View ties Model and Template together
from django.shortcuts import render
from .models import Post

def post_list(request):
    posts = Post.objects.all()          # Model
    return render(request, "posts.html", {"posts": posts})  # Template

Learn it in a lesson

See also

Back to the Dictionary