We are no longer supporting this project. It has moved: https://github.com/allanjamesvestal/grappelli-nested-inlines
Extends Alain Trinh (http://github.com/Soaa-/)'s django-nested-inlines code to work with the latest version of Django Grappelli.
Patches have been submitted, and repositories forked, but no one likes to use either one. Now, nested inlines are available in an easy-to-install package.
This is still beta-quality software, and certainly has its share of bugs. Use it in production sites at your own risk.
pip install grappelli-nested-inlines
grappelli_nested.admin
contains three ModelAdmin
subclasses to enable
nested inline support: NestedModelAdmin
, NestedStackedInline
, and
NestedTabularInline
. To use them:
- Add
grappelli_nested
to yourINSTALLED_APPS
beforegrappelli
anddjango.contrib.admin
. This is because this app overrides certain admin templates and media. - Run
./manage.py collectstatic
to get the new CSS and Javascript files that come with grappelli-nested-inlines. - Import
NestedModelAdmin
,NestedStackedInline
, andNestedTabularInline
wherever you want to use nested inlines. - On admin classes that will contain nested inlines, use
NestedModelAdmin
rather than the standardModelAdmin
. - On inline classes, use
Nested
versions instead of the standard ones. - Add an
inlines = [MyInline,]
attribute to your inlines and watch the magic happen.
from django.contrib import admin
from grappelli_nested.admin import NestedModelAdmin, NestedStackedInline, NestedTabularInline
from models import A, B, C
class MyNestedInline(NestedTabularInline):
model = C
class MyInline(NestedStackedInline):
model = B
inlines = [MyNestedInline,]
class MyAdmin(NestedModelAdmin):
pass
admin.site.register(A, MyAdmin)
As Trinh said himself, this package is mainly the work of other developers. I (Vestal) have merely adapted this package to support Django Grappelli (as Trinh says he's taken other developers' patches "and packaged them nicely for ease of use").
Besides Trinh, additional credit goes to:
- Gargamel for providing the base patch on the Django ticket.
- Stefan Klug for providing a fork with the patch applied, and for bugfixes.