#9025: Nested Inline Support in Admin
-------------------------------+------------------------------------
     Reporter:  pixelcort      |                    Owner:  Gargamel
         Type:  New feature    |                   Status:  assigned
    Component:  contrib.admin  |                  Version:  master
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Accepted
    Has patch:  1              |      Needs documentation:  0
  Needs tests:  1              |  Patch needs improvement:  1
Easy pickings:  0              |                    UI/UX:  1
-------------------------------+------------------------------------
Changes (by pztrick):

 * cc: pztrick (added)


Comment:

 I applied the above patch (nested_inlines_2.diff) to the latest master
 branch today (v1.5alpha latest commit #bfcda7781a) and it appears to work
 very well.

 {{{
 myApp.admin.py
 --------
 from django.contrib import admin
 from myApp.models import Project, Parcel, Plot, Tree

 class TreeInline(admin.TabularInline):
     model = Tree
     fields = ('genus','species','dbh')
     extra = 0

 class PlotInline(admin.StackedInline):
     model = Plot
     fields = ('name','shape_reported','area_reported')
     inlines = [TreeInline, ]
     extra = 0

 class ParcelInline(admin.StackedInline):
     model = Parcel
     fields = ('name','area_reported')
     inlines = [PlotInline, ]
     extra = 0

 class ProjectAdmin(admin.ModelAdmin):
     fields = ('name','owner')
     inlines = [ParcelInline, ]
 }}}

 The resulting screenshot is here: http://i46.tinypic.com/2qjzvkn.png

 Implementation is as simple as adding an {{{inlines}}} definition to the
 (inherited) TabularInline or StackedInline class (which is already
 supported in the admin.ModelAdmin class). This is exactly what I had
 originally tried to do before learning it was not supported, so I would
 say its a very slick enhancement. Thank you Gargamel.

 I will report back any new issues if I encounter them. (Changes did save
 correctly for me.)

 Next steps: docs and tests (?)

-- 
Ticket URL: <https://code.djangoproject.com/ticket/9025#comment:112>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to