{"id":4931,"library":"django-nested-admin","title":"Django Nested Admin","description":"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.","status":"active","version":"4.1.6","language":"en","source_language":"en","source_url":"https://github.com/theatlantic/django-nested-admin","tags":["django","admin","nested","inlines","forms"],"install":[{"cmd":"pip install django-nested-admin","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency for Django admin functionality.","package":"Django","optional":false},{"reason":"Provides enhanced admin UI; django-nested-admin offers specific compatibility fixes for it.","package":"django-grappelli","optional":true}],"imports":[{"symbol":"NestedModelAdmin","correct":"from nested_admin import NestedModelAdmin"},{"symbol":"NestedStackedInline","correct":"from nested_admin import NestedStackedInline"},{"symbol":"NestedTabularInline","correct":"from nested_admin import NestedTabularInline"}],"quickstart":{"code":"from django.contrib import admin\nfrom django.db import models\n\nfrom nested_admin import NestedModelAdmin, NestedStackedInline, NestedTabularInline\n\n# Example Models\nclass Grandparent(models.Model):\n    name = models.CharField(max_length=100)\n\n    def __str__(self):\n        return self.name\n\nclass Parent(models.Model):\n    grandparent = models.ForeignKey(Grandparent, on_delete=models.CASCADE, related_name='parents')\n    name = models.CharField(max_length=100)\n\n    def __str__(self):\n        return self.name\n\nclass Child(models.Model):\n    parent = models.ForeignKey(Parent, on_delete=models.CASCADE, related_name='children')\n    name = models.CharField(max_length=100)\n\n    def __str__(self):\n        return self.name\n\n\n# Admin Inlines\nclass ChildInline(NestedTabularInline):\n    model = Child\n    extra = 1\n\nclass ParentInline(NestedStackedInline):\n    model = Parent\n    inlines = [ChildInline]\n    extra = 1\n\n@admin.register(Grandparent)\nclass GrandparentAdmin(NestedModelAdmin):\n    inlines = [ParentInline]\n    list_display = ('name',)\n\n# Register Parent and Child models to ensure they appear in admin if not directly inline\n# admin.site.register(Parent)\n# admin.site.register(Child)\n","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade your Django project to Django 3.2+ and Python 3.6+ before upgrading to django-nested-admin v4.0.0 or later.","message":"Version 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.","severity":"breaking","affected_versions":"<4.0.0"},{"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.","message":"Version 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.","severity":"breaking","affected_versions":"<4.1.0"},{"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.","message":"`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.","severity":"gotcha","affected_versions":"All 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.","message":"Integration 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"If 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.","severity":"gotcha","affected_versions":">=4.0.0"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}