--- id: drf-nested-routers version: "0.95.3" license: Apache-2.0 license_treatment: permissive maintenance: active --- # drf-nested-routers — Nested resources for the Django Rest Framework License: permissive · Maintenance: active · Downloads: 2.2M/mo ## 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 above — verify before relying. Provides routers and serializer fields for Django REST Framework to build nested REST API resources where child resources are scoped within parent resources. 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 pip install drf-nested-routers uv add drf-nested-routers poetry add drf-nested-routers ## Installing drf-nested-routers 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+. 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') 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. 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_current - Install friction: low - Maintenance: active - Downloads: 2.2M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags nested REST API routes, django rest framework nested resources, hierarchical API endpoints, parent-child resource routing, drf nested routers, RESTful nested URL patterns, rest-api, django-extension [View on SkillFed](https://skillfed.io/packages/drf-nested-routers) · [View on PyPI](https://pypi.org/project/drf-nested-routers/)