drf-nested-routers
Nested resources for the Django Rest Framework
Decision gist · record as of 2026-08-14
Yes. The package is actively maintained (last commit 2026-08-10), has no known vulnerabilities, low install friction, and solves a genuine problem in REST API design. It is production-stable and widely used (top 5000 PyPI packages). Install it if you need to build hierarchical REST APIs with Django and Django REST Framework without manual routing logic.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or higher; Django 4.2, 5.0, 5.1, or 5.2; and Django REST Framework 3.14, 3.15, or 3.16.
- Low friction install with only two runtime dependencies (Django and djangorestframework).
- Actively maintained with recent releases; last commit 2026-08-10.
License · maintenance · safety
Apache-2.0 (permissive) — Apache-2.0 permissive license allows use in commercial and private projects with minimal restrictions; attribution required.
last release 2026-07-31 (14 days) · last repo commit 2026-08-10 · 1,799 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 2,158,642 downloads/mo, #3,244 on PyPI
Alternatives
Verify before relying
pip install drf-nested-routers
from drf_nested_routers import routers
router = routers.SimpleRouter()
router.register(r'domains', DomainViewSet)
domains_router = routers.NestedSimpleRouter(router, r'domains', lookup='domain')
domains_router.register(r'nameservers', NameserverViewSet, basename='domain-nameservers')- Whether the package fully handles all edge cases in production; the description notes it 'works for me' but cannot warranty full compatibility everywhere.
- Performance characteristics when nesting resources three or more levels deep.
- Compatibility with custom authentication or permission classes in nested contexts.
What it is and what it does
drf-nested-routers extends Django REST Framework's routing system to handle nested resources—child resources that logically belong within parent resources. Instead of flat URLs like /domains/ and /nameservers/, it generates hierarchical URLs like /domains/{domain_pk}/nameservers/{pk}, where the nameserver is always accessed in the context of its parent domain. This is essential for building truly RESTful APIs where resource relationships are reflected in the URL structure.
The package provides NestedSimpleRouter and NestedDefaultRouter classes that chain off parent routers, plus optional serializer fields for building hyperlinks in nested contexts. It supports arbitrary nesting depth—you can nest routers multiple levels deep—and works with both Django ORM-based viewsets and custom ViewSet implementations. The package is lightweight, requires no Django app registration, and integrates directly into your URL configuration.
Use it for
- Build a multi-tenant API where teams have projects and projects have tasks, with hierarchical URL scoping.
- Create a domain management API where domains have nested nameservers, SSL certificates, or DNS records scoped to each domain.
- Implement a content management system with nested resources like sites containing pages containing comments.
- Design a SaaS API with organizations, workspaces, and resources nested within each, maintaining proper authorization boundaries.
- Build a file system-like API structure with folders containing subfolders and files, using nested routers to reflect the hierarchy.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package is actively maintained (last commit 2026-08-10), has no known vulnerabilities, low install friction, and solves a genuine problem in REST API design. It is production-stable and widely used (top 5000 PyPI packages). Install it if you need to build hierarchical REST APIs with Django and Django REST Framework without manual routing logic.
Install
drf-nested-routers on PyPI
Before you install
Low friction install with only two runtime dependencies (Django and djangorestframework). Actively maintained with recent releases; last commit 2026-08-10. Requires Python 3.10 or higher and Django 4.2+.
Requires Python 3.10 or higher; Django 4.2, 5.0, 5.1, or 5.2; and Django REST Framework 3.14, 3.15, or 3.16.
License in practice
Apache-2.0 permissive license allows use in commercial and private projects with minimal restrictions; attribution required.
Quickstart
pip install drf-nested-routers
from drf_nested_routers import routers
router = routers.SimpleRouter()
router.register(r'domains', DomainViewSet)
domains_router = routers.NestedSimpleRouter(router, r'domains', lookup='domain')
domains_router.register(r'nameservers', NameserverViewSet, basename='domain-nameservers')
Verify before relying
- Whether the package fully handles all edge cases in production; the description notes it 'works for me' but cannot warranty full compatibility everywhere.
- Performance characteristics when nesting resources three or more levels deep.
- Compatibility with custom authentication or permission classes in nested contexts.
Package facts
| License | Apache-2.0 permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagesdjangorestframeworkDjango |
| Maintenance | Actively maintained 14 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,158,642 / month, #3,244 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 4.2Framework :: Django :: 5.0Framework :: Django :: 5.1Framework :: Django :: 5.2Intended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Topic :: Internet :: WWW/HTTP |
Evidence: drf_nested_routers-0.95.3-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “django rest framework nested resources”
- drf-nested-routersProvides routers and serializer fields for Django REST Framework to…
- drf-flex-fieldsAdds dynamic field expansion and sparse field selection to Django…
- django-tastypiedjango-tastypie provides a REST API framework for Django that…
Give your agent the search over MCP, or paste the wish link into any chat.
More WWW/HTTP packages
urllib3 is an HTTP client library that provides thread-safe connection pooling, SSL/TLS verification, multipart file uploads, request retries, compression support, and proxy handling for Python applications.
Requests is a Python HTTP library that simplifies sending HTTP/1.1 requests with automatic handling of headers, authentication, cookies, and response parsing.
h11 is a pure-Python HTTP/1.1 protocol implementation that handles parsing and serializing HTTP messages without any built-in I/O, letting you integrate it with any network layer you choose.
HTTPX is a fully featured HTTP client library for Python that provides both sync and async APIs, with support for HTTP/1.1 and HTTP/2, plus an integrated command-line client.
Install it if you are building new projects or modernizing existing ones that rely on HTTP.
A minimal low-level HTTP client library that sends HTTP requests with thread-safe and task-safe connection pooling, supporting HTTP/1.1, HTTP/2, proxies, and both sync and async interfaces.
aiohttp is an async HTTP client and server framework built on asyncio, supporting both WebSockets and middleware-based routing for building concurrent web applications.
Install it if you need async HTTP client or server capabilities in asyncio-based applications.
See also drf-writable-nested · djangorestframework-role-filters · django-rest-polymorphic · drf-flex-fields · django-hosts · django-rest-multiple-models · django-tree-queries · rest-framework-generic-relations · drf-dynamic-fields · djangorestframework