The DRF questions backend interviews keep returning to, what each one tests, and short answers checked against the official docs.
The Django REST Framework interview questions worth preparing come down to four things: how serializers turn models into JSON and validate input, how viewsets and routers wire up endpoints, how authentication differs from permissions, and whether you can keep an API fast and safe once it has real data. If you can explain each and write a small viewset that only shows users their own records, you are in good shape. Below are twelve questions grouped by topic, a worked example that ties several together, and a one-week prep plan.
How DRF shows up in an interview
Prepare for two modes. In the first, you talk through concepts. In the second, you build or fix an endpoint, live or as a take-home. Reading the docs prepares you for the first mode only, so practise writing code, not just answers.
Serializers and views
1. What does a serializer do?
It converts model instances and querysets to Python data that renders as JSON, and it validates incoming data before you save it. Pass many=True to serialize a collection and partial=True to allow updates that omit required fields.
2. Serializer or ModelSerializer?
Tests: judgement. ModelSerializer builds fields from the model, generates validators such as unique_together, and gives you default create() and update(). Use a plain Serializer for payloads that do not map to one model.
3. Where does validation go?
Field rules go in validate_<field_name>(), which receives that one value. Rules that compare fields go in validate(). A good follow-up point: on a partial update, validate() only sees the fields the client sent.
4. Can you write to a nested serializer?
Tests: whether you have actually tried. Not by default. DRF requires you to write create() and update() yourself for nested data; the docs point to the third-party DRF Writable Nested package as an alternative.
5. ViewSet or APIView?
A viewset provides actions such as list() and create() instead of get() and post(), and a router builds the URLs. The DRF docs make the trade-off plainly: regular views and URL confs are more explicit and give more control, while viewsets get you running quickly and keep URLs consistent across a large API. Add extra endpoints with @action(detail=True) or detail=False.
Security
6. Authentication versus permissions?
Authentication identifies who made the request; permissions decide whether that user may do this. If you set no permission policy, DRF allows unrestricted access, which is worth saying out loud.
7. Why did a user see records they should not?
Object-level permissions (has_object_permission) run when a generic view calls get_object(), so on detail routes. The docs state that generic views do not apply object-level permissions to each instance in a list. Filter the list in get_queryset() instead.
8. Token authentication or JWT?
DRF's TokenAuthentication is a simple implementation suited to native desktop and mobile clients. JWT is not built in; the docs list djangorestframework-simplejwt as a third-party package. They also mention Knox for multiple tokens per user and token expiry. Session authentication suits AJAX clients running in the same session context as your website, and unsafe methods such as POST, PUT, PATCH and DELETE then need a valid CSRF token.
9. Is throttling a security control?
No, and the docs say so: it should not be treated as protection against brute force or denial of service. It limits request rates and uses Django's cache backend. Clients behind a shared NAT gateway can be counted as one client, depending on how NUM_PROXIES is configured.
10. How do you handle CORS?
In middleware. The DRF docs suggest adding the headers in middleware and name django-cors-headers as a package known to work with REST framework.
Performance and production
11. Why is this list endpoint slow?
Usually N+1 queries: the serializer touches a related object for every row. Use select_related() for foreign keys (one query with a SQL join) and prefetch_related() for many-to-many and reverse relations (a separate query per relationship, joined in Python). Put them in get_queryset(), and call get_queryset() rather than reading the queryset attribute, which DRF evaluates once and caches across requests. Then add pagination: it is off by default. CursorPagination stays fast on large tables and, used with a unique, unchanging ordering, avoids showing a client the same item twice.
12. How do you test and version an API?
Use APITestCase, whose self.client is an APIClient; force_authenticate() skips the login step. APIClient does not enforce CSRF by default, so a session-auth test can pass while the browser fails. Versioning is off by default; DRF ships URL path, namespace, host name, query parameter and Accept header schemes.
Worked example: a notes API that only shows your own notes
from rest_framework import permissions, viewsets
class IsOwner(permissions.BasePermission):
def has_object_permission(self, request, view, obj):
return obj.owner == request.user
class NoteViewSet(viewsets.ModelViewSet):
serializer_class = NoteSerializer
permission_classes = [permissions.IsAuthenticated, IsOwner]
def get_queryset(self):
return Note.objects.filter(owner=self.request.user).select_related("owner")
def perform_create(self, serializer):
serializer.save(owner=self.request.user)
# urls.py
router.register("notes", NoteViewSet, basename="note")What makes this answer strong: get_queryset() scopes the list, because IsOwner alone would not filter it (question 7). perform_create() sets the owner on the server, so the client cannot assign a note to someone else. select_related avoids a query per row (question 11). And basename is required because the viewset has no queryset attribute, so the router cannot infer the URL name. A weak answer sets queryset = Note.objects.all() and relies on the permission class.
A one-week prep plan
- Days 1–2: Build the notes API above from an empty project, with a model, serializer, viewset and router.
- Days 3–4: Add token authentication, pagination and a nested serializer you can write to. Break the permissions on purpose and explain the failure.
- Day 5: Write APITestCase tests for the list, detail and create routes, including one user trying to read another's note.
- Days 6–7: Answer the twelve questions out loud, in under two minutes each.
For mock rounds, Verve AI's Python interview copilot listens to the question and shows suggestions only you can see, and its Software Engineering domain covers algorithms, system design and DevOps. For coding screens, see the Coding Copilot. Related: technical round interview questions and SQL interview questions for three years of experience.
Sources
- Serializer roles, many/partial, ModelSerializer defaults, validation methods, nested writes: https://www.django-rest-framework.org/api-guide/serializers/
- ViewSet definition, ModelViewSet actions, @action, views vs viewsets trade-off: https://www.django-rest-framework.org/api-guide/viewsets/
- Default AllowAny policy, object permissions only via get_object, not applied to lists: https://www.django-rest-framework.org/api-guide/permissions/
- TokenAuthentication scope, JWT as third party (simplejwt), Knox, session auth and CSRF: https://www.django-rest-framework.org/api-guide/authentication/
- Throttling not a security measure, cache backend, NAT clients: https://www.django-rest-framework.org/api-guide/throttling/
- CORS via django-cors-headers: https://www.django-rest-framework.org/topics/ajax-csrf-cors/
- get_queryset vs cached queryset attribute, perform_create, select/prefetch in get_queryset: https://www.django-rest-framework.org/api-guide/generic-views/
- select_related and prefetch_related behaviour: https://docs.djangoproject.com/en/5.2/ref/models/querysets/
- Pagination off by default, CursorPagination properties and ordering requirement: https://www.django-rest-framework.org/api-guide/pagination/
- APITestCase, APIClient, force_authenticate, CSRF not enforced by default: https://www.django-rest-framework.org/api-guide/testing/
- Versioning off by default, built-in schemes: https://www.django-rest-framework.org/api-guide/versioning/
- basename required without a queryset attribute: https://www.django-rest-framework.org/api-guide/routers/
- Verve product claims: https://docs.vervecopilot.com/features/interview-copilot
Ryan
CEO of Verve AI







