OctogleHire
← Interview questions library

25 Django interview questions

Structure the Django interview loop around evidence, not recall. Start with a short screening call to confirm Python, Django, database, and remote collaboration experience. Use a practical coding stage to test model design, query efficiency, tests, and API behavior in a small existing codebase. Follow with a debugging review where the candidate explains a slow view, failing transaction, or production error. Add a system design interview for choices around Django, PostgreSQL, caching, queues, and deployment. For senior and lead candidates, include a code review and leadership conversation covering trade-offs, migration planning, incident response, and mentoring. Keep each stage tied to work the role will actually do.

Junior Django questions

Fundamentals, learning speed and how they debug.

  1. 01A page that lists projects has become slow after adding each project's owner and latest comment. How would you investigate and improve it in a Django app?

    Listen for: A strong junior candidate starts with reproducing the issue locally, checking the Django Debug Toolbar or query logs, and looking for N+1 queries. They should mention select_related for single-valued relationships, prefetch_related for many-valued relationships, limiting fields only when useful, and confirming the improvement with tests or query counts.

    Red flag: They suggest adding caching first without checking the generated SQL or query count.

  2. 02You need to add a `status` field to an existing `Order` model that already has production data. How would you approach the migration?

    Listen for: Listen for safe incremental thinking: add the field with a default or nullable phase, backfill existing rows if needed, then tighten constraints once data is valid. They should understand Django migrations are code, know how to inspect generated migrations, and consider rollback, large tables, and coordination with deployed application code.

    Red flag: They assume every migration can be run in one step because Django generated it.

  3. 03How would you test a Django REST endpoint that creates a record and sends an email?

    Listen for: They should describe testing request validation, permissions, response status, database side effects, and email behavior using Django's test client, DRF APIClient, or pytest-django. Good answers avoid hitting real external services, use locmem email backend or mocks, and include both success and failure cases.

    Red flag: They only test that the endpoint returns 200 and ignore permissions, validation, and side effects.

  4. 04A form accepts user input and saves a model. Where would you put validation, and why?

    Listen for: Look for separation of concerns: field-level checks in form or serializer validation, model constraints for rules that must always hold, and database constraints for integrity. They should understand that client-side validation is only convenience and that validation needs clear error messages and tests around edge cases.

    Red flag: They put all validation in the view because it feels simpler.

  5. 05What would you check before exposing a new Django admin page to operations users?

    Listen for: A good answer covers permissions, list_display and search_fields for usability, query performance for changelists, readonly_fields for sensitive data, auditability, and avoiding unsafe custom actions. They should know Django admin is powerful but not automatically appropriate for every internal workflow.

    Red flag: They treat staff access as equivalent to unrestricted production database access.

  6. 06You see a `DoesNotExist` error in production logs for a view that usually works. How would you debug and fix it?

    Listen for: They should ask what object is missing, inspect the URL parameters and query assumptions, reproduce with relevant data, and handle expected absence with get_object_or_404 or explicit error handling. Strong answers mention permissions, race conditions, deleted records, logging useful context, and adding a regression test.

    Red flag: They wrap the whole view in a broad `except Exception` and return a generic success response.

Mid-level Django questions

Independent delivery, trade-offs and code quality.

  1. 07How do you decide whether business logic belongs in a Django model, manager, service function, serializer, or view?

    Listen for: Strong candidates explain trade-offs rather than a rigid rule. They keep views thin, put persistence invariants near models and constraints, use managers/querysets for reusable database access, and use service functions for workflows that touch several models or external systems. They also mention testability and avoiding serializers becoming transaction scripts.

    Red flag: They insist on one pattern for all logic regardless of complexity or team conventions.

  2. 08A Celery task charges a customer and updates an invoice. The task sometimes runs twice. How would you make it safe?

    Listen for: Listen for idempotency keys, database uniqueness constraints, state transitions, transaction.atomic, select_for_update where appropriate, and separating external calls from local commits carefully. They should discuss retries, timeouts, task acknowledgments, and storing provider response IDs so duplicate executions do not duplicate charges or corrupt invoice state.

    Red flag: They say Celery tasks should never run twice, so duplicate handling is unnecessary.

  3. 09You are reviewing a pull request that adds `.values()` and `.only()` to speed up queries. What would you look for?

    Listen for: A strong answer checks whether the change actually reduces query time, memory, or serialization cost and whether it breaks model methods, deferred field access, or type expectations. They should compare with select_related, prefetch_related, annotations, indexes, and pagination, and ask for query plans or benchmarks when the path is hot.

    Red flag: They assume `.only()` is always faster without considering deferred queries or maintainability.

  4. 10How would you implement object-level permissions for a Django REST API used by multiple organizations?

    Listen for: Look for tenant scoping at the queryset level, not just post-fetch checks. They should discuss DRF permission classes, filtering by organization membership, avoiding IDOR bugs, tests for cross-tenant access, database constraints, and possibly row-level security if the risk profile justifies it.

    Red flag: They rely on hiding unauthorized objects in the frontend.

  5. 11A release includes a data migration that backfills a computed field for millions of rows. What concerns do you raise?

    Listen for: They should mention locking, transaction size, batching, resumability, observability, and whether the backfill should run outside the schema migration. Good answers include deploying compatible code first, using RunPython carefully, avoiding model methods that may change later, and validating results before enforcing non-null or unique constraints.

    Red flag: They put a long Python loop inside a single migration transaction with no batching or monitoring.

  6. 12How do you handle settings for local development, CI, staging, and production in a Django project?

    Listen for: Strong answers use environment-based configuration with typed parsing where useful, secret management outside source control, safe defaults, and explicit settings for allowed hosts, CSRF trusted origins, databases, caches, email, logging, and debug mode. They should mention tests that prevent unsafe production settings and clear local onboarding.

    Red flag: They commit production secrets to `settings.py` or depend on developers manually editing files.

  7. 13A DRF endpoint returns nested objects and is slow under load. What steps would you take before changing the response shape?

    Listen for: They should profile serialization and database access separately, inspect query counts, use select_related/prefetch_related or Prefetch objects, add indexes where needed, and review pagination. They may consider denormalized read models, caching, or simpler serializers, but should validate the bottleneck before breaking API contracts.

    Red flag: They immediately remove fields from the API without measuring or considering compatibility.

Senior Django questions

Judgement, architecture and raising the team's bar.

  1. 14You inherit a large Django monolith with inconsistent patterns and slow delivery. How do you improve it without a risky rewrite?

    Listen for: Look for incremental strategy: map domains, stabilize tests, define conventions, isolate high-change areas, improve observability, and pay down painful coupling as part of feature work. Strong candidates discuss architectural seams, migration plans, team alignment, and when extracting services is justified versus when a modular monolith is better.

    Red flag: They propose rewriting the application into microservices before understanding domain boundaries and failure modes.

  2. 15How would you design a zero-downtime deployment process for Django schema changes?

    Listen for: They should describe expand-and-contract migrations, backwards-compatible code, avoiding long locks, adding nullable columns before enforcing constraints, concurrent index creation for PostgreSQL, feature flags, and deploy ordering. Strong answers include rollback limitations, migration observability, and coordination between application instances during rolling deploys.

    Red flag: They assume running `manage.py migrate` during deploy is always safe and instantly reversible.

  3. 16A critical view intermittently returns stale data after introducing Redis caching. How would you diagnose and redesign it?

    Listen for: Strong candidates ask what is cached, key design, TTLs, invalidation paths, transaction timing, and whether replicas or async tasks are involved. They discuss cache-aside versus write-through, versioned keys, selective invalidation, dogpile protection, and when correctness should favor database reads over cache hits.

    Red flag: They only lower the TTL and consider the issue solved.

  4. 17How do you evaluate whether to use Django signals for a new cross-cutting workflow?

    Listen for: They should know signals can decouple simple local reactions but often hide control flow, complicate transactions, and surprise tests. Good answers compare explicit service orchestration, domain events, outbox patterns, and Celery tasks. They also mention using transaction.on_commit when side effects depend on committed data.

    Red flag: They use signals for every side effect because it keeps views and models short.

  5. 18Your team must upgrade from Django 4.2 LTS to Django 5.2 LTS or 6.x. How would you plan it?

    Listen for: Listen for reading release notes and deprecation timelines, upgrading dependencies first, running tests with warnings treated seriously, checking middleware, async behavior, templates, database backends, and authentication changes. Strong answers use CI matrices, incremental pull requests, staging verification, and clear rollback plans.

    Red flag: They change the version pin and fix failures only after production breaks.

  6. 19How would you investigate high PostgreSQL CPU caused by a Django endpoint that uses complex ORM annotations?

    Listen for: They should capture the SQL, use EXPLAIN ANALYZE, inspect indexes, row estimates, joins, sort operations, and generated subqueries. Strong answers compare ORM readability against raw SQL or database views, consider materialized data for hot paths, and verify improvements with realistic data rather than small fixtures.

    Red flag: They keep adding indexes randomly without looking at the query plan.

  7. 20How do you balance DRF serializers, django-filter, and custom query code as an API grows?

    Listen for: A senior answer separates representation, validation, filtering, and query planning. They watch for serializers triggering hidden queries, filters exposing expensive operations, and duplicated authorization logic. They may introduce explicit read serializers, service/query modules, schema documentation, and compatibility policies without over-engineering simple endpoints.

    Red flag: They let each endpoint evolve independently with no shared permission, filtering, or response conventions.

System design Django questions

Designing real systems end to end.

  1. 21Design a multi-tenant SaaS platform in Django where each customer has users, projects, billing records, and strict data isolation.

    Listen for: Strong answers compare shared-schema tenant keys, schema-per-tenant, and database-per-tenant approaches. They should cover tenant scoping in managers/querysets, middleware, permissions, unique constraints including tenant IDs, background tasks, admin safety, tests for cross-tenant access, and optional PostgreSQL row-level security for defense in depth.

    Red flag: They rely on passing `organization_id` from the client and trusting it throughout the stack.

  2. 22Design a Django-based file processing system where users upload large CSV files and receive validation results asynchronously.

    Listen for: Look for direct-to-object-storage uploads or streamed handling, model state transitions, Celery or a managed queue, chunked parsing, idempotent tasks, progress tracking, error reporting, and transaction boundaries. Strong answers discuss file type validation, size limits, antivirus or content scanning if required, and not blocking web workers.

    Red flag: They parse the whole file synchronously inside the request and store it in memory.

  3. 23Design an audit log for sensitive changes made through Django admin and APIs.

    Listen for: They should capture actor, timestamp, source, object identity, before/after values where appropriate, request correlation ID, and reason fields for sensitive actions. Strong answers discuss immutable append-only storage, privacy concerns, admin actions, bulk updates, service-level logging, and querying audit records without coupling every model too tightly.

    Red flag: They only enable default application logs and assume that is an audit trail.

  4. 24Design a read-heavy reporting feature in Django over transactional data that product teams want to filter and export.

    Listen for: Strong answers separate transactional writes from reporting reads when needed, using optimized ORM queries, indexes, denormalized summary tables, materialized views, or a warehouse export depending on freshness needs. They cover permissions, pagination, asynchronous exports, query timeouts, and preventing arbitrary filters from hurting the primary database.

    Red flag: They build one unrestricted admin-style query endpoint directly against production tables.

  5. 25Design a real-time notifications feature for a Django app that supports web, email, and mobile push channels.

    Listen for: Listen for a notification model, user preferences, event generation after transaction commit, channel-specific delivery workers, idempotency, retry handling, and unread state. Strong candidates compare Django Channels/WebSockets, Server-Sent Events, polling, and external push providers, and avoid coupling notification delivery to request latency.

    Red flag: They send every notification synchronously from the view before returning the response.

Practical task · 2–3 hours

Build and Optimize a Django Project Activity API

Provide a small Django 5.2 or 6.x project with models for Organization, UserProfile, Project, Task, and Comment plus a few failing tests. Ask the candidate to implement a DRF endpoint that lists projects for the current user's organization, including task counts and the latest comment summary. They must add object-level access control, fix the failing tests, add at least two meaningful tests, and address an intentional N+1 query problem. The exercise can be completed live with discussion or as a 2–3 hour take-home with a short README explaining trade-offs.

How to evaluate it

  • Correct tenant scoping and permission behavior, including cross-organization denial.
  • Efficient ORM usage with bounded query count and no hidden N+1 in serializers.
  • Clear tests for success, validation or permission failure, and query behavior.
  • Readable Django/DRF code with logic placed in maintainable layers.
  • Practical explanation of trade-offs, assumptions, and what they would improve next.

Rather skip the interview loop?

Every Octogle Django engineer has already passed a technical assessment, system design and a live interview with an engineer who has shipped Django. Send a brief and get 3–5 scored profiles in 48 hours.