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

Comment (by anonymous):

 Hi,

 I'm very desperate trying to get these inlines, but it  does not show my
 third line. I installed the new django-nested-inlines which is said to fix
 the bugs. But I still cannot get the nested inlines!

 I have python 2.7 and the newest nested_inlines I can get via pip install
 django-nested-inlines.

 Replying to [comment:112 pztrick]:
 > 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.

 I got a simple model:

 class A(models.Model):
         name = models.CharField(max_length = 200)

 class B(models.Model):
         name = models.CharField(max_length = 200)
         fk_a = models.ForeignKey('A')

 class C(models.Model):
         name = models.CharField(max_length = 200)
         fk_b = models.ForeignKey('B')

 and in admin:

 class myNestedTwo(admin.TabularInline):
     model = C

 class myNested(admin.TabularInline):
     model = B
     inlines = [myNestedTwo,]

 class myAdmin(admin.ModelAdmin):
     inlines=[myNested,]

 admin.site.register(A, myAdmin)

 I also tried that with NestedModelAdmin and so on, but it does not work.

 Can you help me please?


 Replying to [comment:112 pztrick]:
 > 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:176>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.b036220d624a23bc4dca10b9267dbff1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to