Django REST Framework – Interview Notes
Quick revision notes for interviews (Junior to Mid-level)
1. Basics
1 Django REST Framework (DRF) is a toolkit built on Django for creating RESTful APIs.
2 REST stands for Representational State Transfer.
3 DRF mainly returns JSON responses (not HTML).
4 Common HTTP methods: GET, POST, PUT, PATCH, DELETE.
2. Serializers
1 Serializer converts Model ↔ JSON and validates data.
2 Serializer: manual field definition.
3 ModelSerializer: auto fields from model, less boilerplate.
4 Field-level validation: validate_().
5 Object-level validation: validate().
3. Views
1 APIView gives full control over HTTP methods.
2 Generic Views provide common CRUD functionality.
3 ViewSet combines multiple actions into one class.
4 ModelViewSet provides full CRUD automatically.
5 [Link] handles JSON, form-data, multipart.
4. Routing
1 Routers automatically generate URLs for ViewSets.
2 Reduces manual URL configuration.
5. Authentication & Permissions
1 Authentication: Who the user is.
2 Permission: What the user can access.
3 Common authentication: Session, Token, JWT.
4 Common permissions: AllowAny, IsAuthenticated, IsAdminUser.
5 JWT is stateless and sent with every request.
6. Pagination, Filtering & Throttling
1 Pagination limits number of records per response.
2 Filtering allows query-based result filtering.
3 SearchFilter and OrderingFilter are commonly used.
4 Throttling limits request rate to prevent abuse.
7. Important Interview Points
1 Templates are NOT required for DRF.
2 DRF is ideal backend for Flutter, React, Angular.
3 PUT = full update, PATCH = partial update.
4 DRF provides browsable API for testing.