What is the MVT architecture in Django?
Why Interviewers Ask This
Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid Django basics — a prerequisite for any developer role.
Answer
Django follows the MVT (Model-View-Template) architectural pattern, which is a variation of the classic MVC: (1) Model: defines the data structure and handles database interactions. Each model class maps to a database table. Models contain fields (CharField, IntegerField, ForeignKey) and methods for business logic. Django's ORM translates model operations to SQL automatically; (2) View: contains the business logic — receives HTTP requests, processes data (querying models, applying logic), and returns HTTP responses. Views are Python functions or class-based views (CBVs). They decide WHAT data to show, not HOW to display it; (3) Template: handles presentation — HTML files with Django Template Language (DTL) for dynamic content rendering. Templates use variables ({{ variable }}), tags ({% if %}, {% for %}), and filters ({{ date|date:"M d, Y" }}). Request flow: Browser → URL Dispatcher (urls.py) → View (views.py) → Model (models.py) → Database → Model → View → Template → HTTP Response → Browser. MVT vs MVC: in MVC, the Controller handles input and coordinates the model and view. In Django's MVT, the framework itself acts as the Controller — URL dispatching routes to the appropriate View, which takes on the Controller's coordination role.
Pro Tip
Before answering, structure your response: one-line definition → real-world analogy → concrete example from a project. This makes even complex Django answers easy to follow.