Registry / web-framework / django-nested-admin

django-nested-admin

JSON →
library4.1.6pypypi✓ verified 23d ago

django-nested-admin provides Django admin classes that allow for deeply nested inlines within the Django administration interface. It extends Django's native `InlineModelAdmin` functionality to support multiple levels of related objects. The current version is 4.1.6, and it typically releases new versions to maintain compatibility with new Django releases.

pip install django-nested-admin
INSTALL
IMPORT
SIG · DJANGO-NESTED-ADMI
D
django-nested-admin
web-frameworkpythonv4.1.6
Install
1.7s avg
Import
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.1.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 20.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.000s · 21MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NestedModelAdmin
from nested_admin import NestedModelAdmin
from nested_admin import NestedModelAdmin
NestedStackedInline
from nested_admin import NestedStackedInline
NestedTabularInline
from nested_admin import NestedTabularInline

To use `django-nested-admin`, define your models, then create `NestedTabularInline` or `NestedStackedInline` classes for your child models, nesting them as needed. Finally, register your top-level model with `NestedModelAdmin` in your `admin.py` file. This example demonstrates a three-level nesting: Grandparent -> Parent -> Child.

from django.contrib import admin from django.db import models from nested_admin import NestedModelAdmin, NestedStackedInline, NestedTabularInline # Example Models class Grandparent(models.Model): name = models.CharField(max_length=100) def __str__(self): return self.name class Parent(models.Model): grandparent = models.ForeignKey(Grandparent, on_delete=models.CASCADE, related_name='parents') name = models.CharField(max_length=100) def __str__(self): return self.name class Child(models.Model): parent = models.ForeignKey(Parent, on_delete=models.CASCADE, related_name='children') name = models.CharField(max_length=100) def __str__(self): return self.name # Admin Inlines class ChildInline(NestedTabularInline): model = Child extra = 1 class ParentInline(NestedStackedInline): model = Parent inlines = [ChildInline] extra = 1 @admin.register(Grandparent) class GrandparentAdmin(NestedModelAdmin): inlines = [ParentInline] list_display = ('name',) # Register Parent and Child models to ensure they appear in admin if not directly inline # admin.site.register(Parent) # admin.site.register(Child)
Debug
Known issues
breakingVersion 4.0.0 removed Python 2.x compatibility and dropped support for all Django versions prior to 3.2. Projects on older Django or Python versions must upgrade or use an older `django-nested-admin` release.
fix
Upgrade your Django project to Django 3.2+ and Python 3.6+ before upgrading to django-nested-admin v4.0.0 or later.
affects: <4.0.0
breakingVersion 4.1.0 updated the signature for `formfield_for_dbfield` and removed usage of deprecated `filter` methods within the codebase. Custom admin classes overriding `formfield_for_dbfield` might need signature adjustments.
fix
Review custom `admin.py` files for any overrides of `formfield_for_dbfield` and update their signatures to match the latest Django/nested-admin expectations. Check `ModelAdmin` and `InlineModelAdmin` documentation for current method signatures.
affects: <4.1.0
gotcha`django-nested-admin` often requires strict alignment with Django's major version. Upgrading Django may necessitate a corresponding upgrade of `django-nested-admin` to ensure compatibility and prevent unexpected behavior or errors.
fix
Always check the `django-nested-admin` release notes and `requirements.txt` for your target version of Django before upgrading. Pin `django-nested-admin` to a compatible version in your project's dependencies.
affects: All versions
gotchaIntegration with `django-grappelli` can sometimes be tricky due to differences in frontend assets and JavaScript event handling. While `django-nested-admin` includes specific fixes for Grappelli, incompatibilities can still arise with certain versions.
fix
Ensure `django-nested-admin` and `django-grappelli` versions are known to be compatible. If issues arise, test with a simpler admin setup to isolate the problem, and consult the `django-nested-admin` GitHub issues for Grappelli-related discussions.
affects: All versions
gotchaIf you are using Django's autocomplete fields or other custom JavaScript in your admin, be aware that `django-nested-admin` (especially v4.0.0+) dispatches native JavaScript CustomEvent events like `formset:added` and `formset:removed`. Your custom JS might need to listen for these.
fix
If custom JavaScript is failing to initialize or re-initialize on dynamically added nested inlines, ensure it's listening for the appropriate `CustomEvent` events dispatched by `django-nested-admin` on the document or relevant formset elements.
affects: >=4.0.0
Upgrade
Version history
4.1.6latest on PyPI · released Oct 23, 2025
Audit
Dependencies
DjangorequiredCore dependency for Django admin functionality.
django-grappellioptionalProvides enhanced admin UI; django-nested-admin offers specific compatibility fixes for it.
Agent activity
17 hits · last 30 days
node
16
Resources
django-nested-admin — pip install django-nested-admin · libregistry