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.

Framework
PyPI
v3.18.3
30,198 stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
91 /100 Excellent
Development Activity 96
Maintenance 72
Community 96
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
90 /100 Excellent
Architecture 92
Code Quality 88
Innovation 78
Learning Curve 100

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 (Serializer and ModelSerializer) 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 authtoken app) 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

Python
63%
GPL 3.0

Paperless-ngx

Bookmarks Archiving

46,451

Turn your paper pile into a searchable digital archive with OCR, AI classification, and automated workflows — all running on your own server.

View details
91
Repo Health
88
Technical
67
Dependency
Built with
Python 63%
TypeScript 28%
Updated 1 weeks ago
TypeScript
51%
Other

Phase Console

Devops · Security

929

End-to-end encrypted secrets management for engineering teams — from local dev to Kubernetes production.

View details
84
Repo Health
73
Technical
63
Dependency
Built with
TypeScript 51%
Python 48%
Updated 2 weeks ago
Python
55%
Other

PostHog

Ab Testing Experimentation · Analytics · Developer Tools

40,208

The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.

View details
92
Repo Health
80
Technical
65
Dependency
Built with
Python 55%
TypeScript 36%
Updated 1 weeks ago
Python
57%
Other

Sentry

Analytics · Developer Tools · Monitoring

45,522

Developer-first error tracking and performance monitoring platform with AI-powered root-cause analysis across 20+ languages and frameworks.

View details
95
Repo Health
80
Technical
66
Dependency
Built with
Python 57%
TypeScript 42%
Updated 1 weeks ago
Python
94%
Apache 2.0

SWIRL

Data Engineering · Databases · Search

3,047

Federated AI search and RAG across 100+ enterprise sources—no data extraction, no vector database required.

View details
60
Repo Health
83
Technical
65
Dependency
Built with
Python 94%
Updated 3 weeks ago
Python
92%
GPL 3.0

Weblate

Developer Tools

6,110

Continuous localization platform that commits translations directly into your version control system with full translator attribution.

View details
95
Repo Health
86
Technical
67
Dependency
Built with
Python 92%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers