1

I am using inlines to allow the editing of the Drivers and Riders objects from Family in the admin, as shown below. I would like the Driver and Rider objects to be collapsed, but it appears that that only works for fields in the class, not fields coming from an inline. Is there a way to collapse Rider and Driver as listed below?

Thanks!

class LegAdmin(admin.ModelAdmin):
    list_display = ('drive_date', 'start_time', 'endpoint')

class DriverInline(admin.StackedInline):
    model = Driver
    extra = 0

class RiderInline(admin.StackedInline):
    model = Rider
    extra = 0

class FamilyAdmin(admin.ModelAdmin):
    inlines = [DriverInline, RiderInline]



#admin.site.register(Driver)
#admin.site.register(Member)
#admin.site.register(Rider)
admin.site.register(Leg, LegAdmin)
# admin.site.register(DriveDay)
admin.site.register(Carpool)
admin.site.register(Family, FamilyAdmin)
admin.site.register(DrivingPreference)
dan1st
  • 12,568
  • 8
  • 34
  • 67
mb52089
  • 872
  • 2
  • 10
  • 24

1 Answers1

0

You could quite easily accomplish this with javascript, just load it within the model:

example

class Media:
   js = ('/media/admin/custom/js/inlinecollapsed.js',)
Hedde van der Heide
  • 21,841
  • 13
  • 71
  • 100
  • Thank you. I am still very new to Django and to programming so I'm not quite sure how to use the advice you've provided – mb52089 Nov 17 '11 at 19:57
  • The Media class adds a custom js (or any media file) to the admin by using the extrajs blocks.. Within the js you can create any effect you want – Hedde van der Heide Nov 18 '11 at 09:29