Skip to main content

Enables nested inlines in the Django/Grappelli admin

Project description

# django-nested-inlines

## Overview

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

[Django issue #9025](http://code.djangoproject.com/ticket/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 -e git+git://github.com/datahub/grappelli-nested-inlines.git#egg=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](https://github.com/stefanklug/django/tree/nested-inline-support-1.5.x).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grappelli-nested-inlines-0.5.0.tar.gz (6.6 kB view details)

Uploaded Source

File details

Details for the file grappelli-nested-inlines-0.5.0.tar.gz.

File metadata

File hashes

Hashes for grappelli-nested-inlines-0.5.0.tar.gz
Algorithm Hash digest
SHA256 a4d3e4a5681d007aead1ef0ad21dc92b5dd3fb0745c49b1faf21009e0c341f3d
MD5 2af83d1d7cf98112bcff4669f88407ec
BLAKE2b-256 7478f18619ca32e535dffec7682610ed59db2fe25c1ed2e61b02944008aa63fe

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page