Backend · Fresher-relevant
Django interview questions on MVT architecture, ORM, middleware, REST framework (DRF), and authentication.
Commonly asked at: Commonly asked at Python-backend product companies and startups such as Swiggy, PhonePe, and Razorpay — general pattern, not company-verified.
Company names below are mentioned only to indicate the general type/level of interview these questions are common at, based on widely known industry patterns. This content is not affiliated with, endorsed by, or sourced from any confidential material of the named companies. All trademarks belong to their respective owners.
What is Django, and what is the MVT pattern?
Tip: Say MVT stands for what, then quickly note how it maps to MVC — that comparison is usually expected.
Django is a high-level Python web framework built for rapid development, with a built-in ORM, admin panel, and auth system out of the box. It follows the MVT pattern — Model, View, Template — which is Django's version of MVC, where Django itself effectively acts as the controller.
What is Django's ORM, and why is it useful?
Tip: Give one code-shape example — `Model.objects.filter(...)` — it makes the answer concrete.
Django's ORM lets you interact with the database using Python classes and methods instead of raw SQL — so querying looks like `User.objects.filter(is_active=True)`. This makes code more portable across databases and reduces SQL injection risk.
What are Django migrations?
Tip: Name the two commands — makemigrations and migrate — that's the core of the expected answer.
Migrations track changes to your models — like adding a field — and translate them into actual database schema changes. `makemigrations` generates the migration file describing the change, and `migrate` applies it to the database, keeping schema changes version-controlled.
Django app vs Django project — what's the difference?
Tip: Use the "one project, many apps" framing — that's the cleanest way to explain it.
A project is the overall Django installation — settings, URLs, WSGI setup for the whole site. An app is a self-contained module for one specific feature, like a "blog" or "users" app — a single project can contain multiple apps, and apps are meant to be reusable.
What are Django middlewares?
Tip: Give one or two real examples — auth, CSRF — abstract definitions alone don't land well here.
Middleware processes requests and responses globally before they reach a view or after a view returns — used for things like authentication checks, CSRF protection, or logging. They're configured as an ordered list in settings.py, and each one can modify or short-circuit the request/response.
select_related vs prefetch_related — what's the difference?
Tip: Tie each to the relationship type — ForeignKey vs ManyToMany — that's the key distinction to state.
Both reduce the number of queries when fetching related objects. `select_related` uses a SQL JOIN and works for single-valued relationships like ForeignKey — one query total. `prefetch_related` runs a separate query per relationship and joins results in Python — used for multi-valued relationships like ManyToMany.
What is Django's admin interface?
Tip: Mention the one-line registration step — `admin.site.register()` — it's a commonly asked detail.
Django auto-generates a fully functional admin panel from your models — you register a model with `admin.site.register(ModelName)`, and it becomes manageable through a web UI without writing custom code. It's especially handy for internal tools and quick data management during development.
How does Django handle authentication and authorization?
Tip: Separate the two clearly — authentication (who you are) vs authorization (what you can do).
Django ships with a built-in auth app providing a User model, login/logout views, password hashing, and session-based authentication. Authorization is handled through permissions and groups, and you can restrict view access with decorators like `@login_required` or `@permission_required`.
What are Django signals, and when would you use them?
Tip: Name one common example — post_save — that's usually the expected reference point.
Signals let certain senders notify other parts of the app when an action happens, without those parts being directly coupled — like `post_save`, which fires right after a model instance is saved. A common use is automatically creating a related profile object whenever a new user is created.
⭐ Scenario: A Django API endpoint is timing out under load. How would you investigate and fix it?
Tip: This is scenario-based — mention concrete diagnostic steps, not generic "optimize the code" advice.
Situation: An API endpoint that used to respond quickly started timing out as traffic and data volume grew.
Task: I needed to find the actual bottleneck and fix it without breaking the endpoint's contract.
Action: I used Django's query logging and `django-debug-toolbar` locally to check for N+1 query problems, and found the serializer was triggering a separate query per related object; I fixed it using `select_related`/`prefetch_related` and added an index on the filtered column.
Result: Response time dropped significantly since the endpoint now ran a small, fixed number of queries instead of one per related object.
InterviewEra generates role-specific questions using your actual projects and skills. Get scored feedback on technical depth, clarity, and structure — free to start.