django-rest-framework
The most widely-used toolkit for building Web APIs on top of Django, with serializers, viewsets, and a built-in browsable API.
Repository Health
Technical Analysis
Django REST Framework (DRF) turns a Django project into a full Web API platform. It layers a serialization system, class-based generic views, viewsets, routers, and pluggable authentication/permission backends on top of Django’s ORM and URL routing, so a ModelViewSet registered with a DefaultRouter can expose a working, browsable CRUD API for a model in a handful of lines.
Beyond CRUD, DRF ships the pieces most APIs eventually need anyway: content negotiation and multiple renderers (JSON, browsable HTML, and custom formats), pagination strategies (page number, limit/offset, cursor), throttling, versioning, an OpenAPI schema generator, and a token-based authtoken app. It’s been the default choice for Python API development since 2011 and remains the reference implementation most other Django API libraries are compared against.
What You Get
- Serializers (
SerializerandModelSerializer) that validate incoming data and control exactly how model/queryset data is rendered, including nested and hyperlinked relations - Generic views and viewsets (
ListCreateAPIView,ModelViewSet, etc.) that implement standard list/create/retrieve/update/destroy behavior via composable mixins - Routers (
SimpleRouter,DefaultRouter) that generate URL confs automatically from registered viewsets, including an optional API root view - A browsable API — every endpoint is also viewable as an interactive, styled HTML page in a browser, with forms for POST/PUT/PATCH
- Pluggable authentication (session, basic, token via the bundled
authtokenapp) and fine-grained permission classes - Pagination (page number, limit/offset, cursor-based), filtering hooks, throttling, and API versioning strategies out of the box
- An OpenAPI schema generator (
rest_framework.schemas) for auto-documenting and exploring the API
Common Use Cases
- Exposing a Django app’s models as a versioned, paginated JSON API for a separate frontend (React/Vue/mobile) to consume
- Building internal/admin APIs where the browsable API’s HTML forms let non-frontend engineers exercise endpoints without Postman
- Adding token-based authentication to a Django backend that also needs to serve a public or partner-facing API
- Layering custom business validation onto Django models via serializer
validate_*/validate()hooks before persisting or returning data - Auto-generating OpenAPI schemas for API documentation tools directly from existing viewsets and serializers
Under The Hood
Architecture
DRF is layered directly on Django’s class-based view system: views.APIView (rest_framework/views.py) subclasses Django’s View and adds content negotiation, request/response wrapping (rest_framework.request.Request, rest_framework.response.Response), and DRF-specific exception handling; generics.GenericAPIView (rest_framework/generics.py) adds queryset/serializer resolution and pagination on top of that; and the mixins in rest_framework/mixins.py (CreateModelMixin, ListModelMixin, etc.) implement the actual list/create/retrieve/update/destroy logic as small, composable classes that generic views and viewsets.ModelViewSet (rest_framework/viewsets.py) combine. Routers (rest_framework/routers.py) close the loop by introspecting registered viewsets and generating Django URL patterns, including an auto-generated API root. Because each layer only depends on the interface of the layer below (queryset/serializer_class attributes, get_serializer(), get_queryset()), swapping the serializer, pagination, or permission classes on a view doesn’t require touching the routing or mixin layer — the design that makes DRF’s generic views composable rather than a single monolithic base class.
Tech Stack
Pure Python 3.10+ with a single hard dependency on Django 5.2/6.0/6.1 (pyproject.toml) — no other runtime dependencies. Optional extras cover common integration points: django-filter for queryset filtering, django-guardian for per-object permissions, markdown and pygments for the browsable API’s documentation rendering, psycopg for Postgres, and pyyaml/uritemplate for the OpenAPI schema tooling. The project builds with setuptools and ships its own authtoken Django app (rest_framework/authtoken/) as a self-contained token-auth add-on with its own models, migrations, and admin registration.
Code Quality
The test suite (tests/) contains over 1,300 test functions across 60+ files covering authentication, serializers, pagination, permissions, filtering, model inheritance edge cases, and the browsable API renderer, run via pytest-django against a real Postgres service in CI across the Python 3.10–3.14 matrix (.github/workflows/main.yml). Pre-commit hooks (isort, flake8 with flake8-bugbear and flake8-tidy-imports, pyupgrade, django-upgrade, codespell) enforce style and catch common Django-upgrade issues before merge. The codebase favors extensive docstrings over static type hints — mypy/pyright are not part of the toolchain — but naming and error-handling (explicit assert guards with descriptive messages in generics.py, structured APIException subclasses in exceptions.py) are consistent throughout.
What Makes It Unique The defining feature that sets DRF apart from comparable API layers is the browsable API itself — every endpoint renders as an interactive HTML page with real input forms for POST/PUT/PATCH, generated automatically from the same serializer that handles JSON, with no extra code from the API author. Combined with the composable mixin/generic-view architecture (each CRUD behavior is a standalone mixin rather than baked into one base class) and a router layer that derives full URL confs from viewset registrations, DRF lets a team go from a Django model to a documented, browsable, authenticated API surface with comprehensive but incremental customization at every layer.
Used by 15 apps in this directory
authentik
Authentication · Security
The self-hosted Identity Provider that replaces Okta, Auth0, and Entra ID with a unified SSO platform supporting SAML, OAuth2/OIDC, LDAP, RADIUS, and WebAuthn.
Baserow
No Code Platforms · Databases
Open-source no-code platform to build databases, apps, automations, and AI agents — self-hosted or cloud, with full data ownership.
Bugsink
Developer Tools · Monitoring
Self-hosted error tracking that accepts Sentry SDKs out of the box, so you keep your instrumentation and drop the monthly bill.
Docs
File Storage · CMS
Open-source collaborative knowledge platform with real-time editing, AI writing tools, and full self-hosting control — built by the French and German governments.
Flagsmith
Developer Tools · Devops · Ab Testing Experimentation
Open-source feature flagging, remote config, and A/B/multivariate testing platform for web, mobile, and server-side apps — self-host or use the hosted SaaS.
Horilla
Human Resources · ERP
Open-source HRMS covering recruitment, attendance, payroll, and biometrics in one self-hosted Django application.
Label Studio
AI Development · Data Engineering
Label Studio is an open-source, multi-type data labeling platform that lets teams annotate images, text, audio, video, and time series data with a configurable XML-based UI and export annotations in formats ready for any ML framework.
LibrePhotos
File Storage
Self-hosted photo library with AI-powered face recognition, semantic search, and automatic event albums — no cloud required.
MaxKB
AI Development · Knowledge Management
Build enterprise-grade AI agents with RAG, workflows & multi-modal support