Python Django developer interview questions and how to answer them
Python Django developer interview questions check whether you can ship and maintain features in a real Django product, not only recite how the framework works. Expect a take-home or pairing task that builds a small API, a code review of a flawed view, and questions on background jobs, data migrations on large tables, the admin, testing and deployment. Hiring teams favor candidates who talk about what broke in production and how they made sure it did not happen twice.
By Evin JohnPublished 8 min read
What Django teams hire for
Django jobs cluster in a few places: product companies with a Django monolith behind a web or mobile app, agencies that build many client sites, and internal tool teams that lean on the admin. In all three the developer spends more time changing existing code than starting new projects. That is why role interviews feel different from a framework quiz. The Django technology guide covers querysets, middleware and security defaults; this page covers the job wrapped around them.
| Team | Typical work | What interviewers probe |
|---|---|---|
| Product company monolith | APIs for web and mobile, background jobs, payments or billing | Migrations without downtime, Celery reliability, query budgets |
| Agency or consultancy | Many smaller projects, CMS sites, handovers | Speed to a clean first version, documentation, client communication |
| Internal tools | Admin customization, reports, imports and exports | Admin performance, permissions, data quality |
| Data-heavy platform | Large tables, reporting endpoints, integrations | Indexes, batching, read replicas, careful backfills |
How the hiring process usually runs
- ScreenWhich Django versions and packages you have used, how big the codebases were, and whether you have run anything in production yourself.
- Python codingA plain Python problem or a data-shaping task. The Python developer guide covers the language side.
- Take-home or pairingBuild a small Django REST Framework API, or extend an existing repo the team gives you. Some teams pair live for an hour instead.
- Code review and designRead a pull request and find problems, then sketch how you would build a feature such as invoicing or notifications.
- Team and behavioralHow you handle incidents, reviews, estimates and disagreements with product.
Take-home questions and what reviewers check
| Question | What it tests | What a strong answer shows |
|---|---|---|
| Walk me through your project layout. | Structure | Apps split by domain, settings read from environment variables, no secrets committed |
| Why did you choose these permissions? | Security by default | Object-level checks so one user cannot read another's records, tested explicitly |
| How would this list endpoint behave with a million rows? | Scale awareness | Pagination, an index on the filter columns, and select_related or prefetch where the serializer needs it |
| What tests did you write and what did you skip? | Judgment | Tests on business rules and permissions first; honest about gaps and time |
| What would you change with another day? | Self-review | Specific items such as rate limiting, better error responses or an audit log |
| How would someone run this locally? | Handover | A README with setup steps, seed data and how to run the tests |
Commit your migrations, keep the commit history readable and write a short note on decisions. Reviewers often open the README and the tests before the views.
The code review exercise
A common format is a short view with several problems. Read it aloud, rank what you find by impact, and propose fixes. Here is the kind of snippet you might get.
from django.http import JsonResponse
from .models import Order
from .tasks import send_receipt
def cancel_order(request, order_id):
order = Order.objects.get(id=order_id)
order.status = "cancelled"
order.save()
send_receipt.delay(order.id)
return JsonResponse({"ok": True})- No ownership check. Any logged-in user, or anyone if the view is not protected, can cancel any order. Filter by the current user or check permissions.
- No method check. A state change should require POST, or the action can be triggered by a link or a crawler.
- Missing object handling. Order.objects.get raises an error for a bad id; get_object_or_404 returns a clean 404.
- Task fired too early. If this runs inside a transaction, the worker may run before the commit and read the old status. Use transaction.on_commit to enqueue after the commit.
- No state rule. A shipped or already cancelled order should not be cancelled again. Put the rule in the model or a service function and test it.
Background jobs and caching questions
- How do you make a Celery task safe to run twice? Make it idempotent: check whether the work is done, use unique keys for external calls, and record completion. Retries and duplicate deliveries happen.
- Why pass an id to a task instead of a model instance? The instance is serialized at enqueue time and goes stale; an id lets the worker load fresh data.
- A task sometimes cannot find the row it was given. Why? It was enqueued before the transaction committed. Fix it with transaction.on_commit.
- How do you handle a task that calls a slow third-party API? Timeouts, retries with backoff, a dead-letter or failure record, and alerts when failures pile up.
- Where would you add caching in a Django app? Expensive, read-heavy data that tolerates slight staleness. Name the key, the expiry and what clears it when data changes.
- What is a cache stampede and how do you avoid it? Many requests rebuild the same expired key at once. Stagger expiries, lock the rebuild or serve stale data while refreshing.
Migrations, upgrades and data questions
- How do you add a required column to a table with millions of rows? Add it as nullable or with a default the database can apply cheaply, backfill in batches in a separate step, then add the constraint. Check how your database version handles defaults.
- How do you rename a field without downtime? Add the new field, write to both, backfill, switch reads, then remove the old one in a later deploy, because old code is still running during a rollout.
- When do you write a data migration instead of a management command? Migrations for changes every environment needs; commands for large or repeatable backfills you want to run and monitor separately.
- How would you plan a Django version upgrade? Read the release notes, fix deprecation warnings on the current version first, check third-party packages, upgrade one step at a time and lean on the test suite.
- Two developers created migrations with the same number. What now? Merge with makemigrations --merge if they do not conflict, or rebase one onto the other, and review the final order.
Admin, testing and deployment questions
- The admin change list for orders is slow. What do you check? list_select_related for foreign keys shown in columns, raw_id_fields or autocomplete_fields for large relations, and indexes on list filters.
- How do you give support staff admin access safely? Groups with the least permissions needed, read-only fields where editing is risky, and logging of changes.
- pytest-django or Django's TestCase? Either works. Explain fixtures, factories for test data, and when you need TransactionTestCase, such as testing on_commit behavior.
- How do you test that an endpoint does not regress on query count? assertNumQueries or the pytest equivalent around the request.
- How is a Django app usually served in production? A WSGI or ASGI server such as Gunicorn or Uvicorn behind a reverse proxy, static files collected and served by the proxy or a CDN, DEBUG off and ALLOWED_HOSTS set.
- When would you choose ASGI? When you need websockets or many long-lived connections, or async views calling slow services. Note that the ORM's async support has limits you should check for your version.
- What do you look at first during a production incident? Error tracking, recent deploys, database load and slow queries, worker queues, then roll back if a deploy is the likely cause.
Behavioral questions for Django developers
- Tell me about a production bug you caused and what you changed afterward.
- Describe a refactor of old Django code. How did you keep it safe?
- How do you respond when a reviewer asks for changes you disagree with?
- Tell me about an estimate that was badly wrong.
- Describe a time you pushed back on a feature because of a data or security risk.
- How do you share knowledge about a part of the codebase only you understand?
- Tell me about a third-party package you removed or replaced, and why.
Fictional example
- We added a nullable discount field to an orders table with about forty million rows, plus a default in the same migration. On our database version that rewrote the table, and the deploy locked writes for several minutes during the afternoon. I helped roll back, then split the change: add the column without the default, backfill in batches of ten thousand from a management command with a pause between batches, then set the default for new rows. The second attempt ran with no lock problems. Since then I add a migration review step to any pull request that touches a big table, and we run the SQL from sqlmigrate before merging.
A two-week preparation plan
- Days 1 to 3: build a small DRF API from scratch with authentication, object permissions, pagination and tests. Time yourself.
- Days 4 to 5: add a Celery task enqueued with on_commit and write a test for it.
- Days 6 to 7: practice a zero-downtime field change and a batched backfill on a local database.
- Days 8 to 10: review the Django guide for ORM questions and read code from an open project to practice spotting problems aloud.
- Days 11 to 14: prepare three production stories, one refactor story, and questions about the team's deploy process and on-call.
Code review rounds reward people who narrate. Natively, an AI interview assistant for Mac and Windows, can read a snippet from a screenshot during practice and talk through issues, and it transcribes your mock review on your computer so you can check whether you ranked problems by impact. With your résumé added (Pro or the free trial), its suggestions for the project questions draw on the work you have actually done.
Questions people ask
What questions are asked in a Python Django developer interview?
Expect a take-home or pairing task building a small API, a code review of a flawed view, and questions on Celery and transactions, migrations on large tables, admin performance, testing and deployment.
What do reviewers look for in a Django take-home?
Committed migrations, object-level permissions, pagination, tests on business rules, settings from environment variables and a README that explains setup and decisions.
How do I answer a question about adding a column to a large table in Django?
Add it in a way that avoids a long table lock, backfill in batches as a separate step, then add the constraint, and check the SQL with sqlmigrate before running it.
Is a Django developer interview different from a Python developer interview?
Yes. It still tests Python, but most of the time goes to web concerns: the ORM, APIs, background jobs, migrations and running Django in production.
Where to go next
Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.
Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.
