Skip to content

Latest commit

 

History

History
65 lines (43 loc) · 2.45 KB

README.md

File metadata and controls

65 lines (43 loc) · 2.45 KB

django-nested-inlines

Overview

Extends Alain Trinh (http://github.com/Soaa-/)'s django-nested-inlines code to work with the latest version of Django Grappelli.

Django issue #9025

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.

Issues

This is still beta-quality software, and certainly has its share of bugs. Use it in production sites at your own risk.

Installation

pip install grappelli-nested-inlines

Usage

grappelli_nested.admin contains three ModelAdmin subclasses to enable nested inline support: NestedModelAdmin, NestedStackedInline, and NestedTabularInline. To use them:

  1. Add grappelli_nested to your INSTALLED_APPS before grappelli and django.contrib.admin. This is because this app overrides certain admin templates and media.
  2. Run ./manage.py collectstatic to get the new CSS and Javascript files that come with grappelli-nested-inlines.
  3. Import NestedModelAdmin, NestedStackedInline, and NestedTabularInline wherever you want to use nested inlines.
  4. On admin classes that will contain nested inlines, use NestedModelAdmin rather than the standard ModelAdmin.
  5. On inline classes, use Nested versions instead of the standard ones.
  6. Add an inlines = [MyInline,] attribute to your inlines and watch the magic happen.

Example

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)

Credits

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.

See Stefan Klug's repository.