Django admin: expand all entries in stackedinline by default

In my django application, I use the admin interface to view all products, and each product can have multiple images. I put the images on the product page using the code below

class ProductImage_Inline(admin.StackedInline): model = ProductImage extra = 3 formfield_overrides = { ImageWithThumbnailField : {'widget' : AdminImageWithThumbnailWidget}, 

By default, on the "Product Administrator" page, I don’t see all the images, because all the entries in StackedInline are collapsed by default. I have to manually click on each of them to expand to see the image.

How do I, by default, expand all entries in StackedInline?

PS: I use the Grappelli theme and suspect that it rolls them by default.

+7
source share
2 answers

I understand that this is a bit late, but with Grappelli 2.3.7 you can now easily do what you are trying to do with the inline_classes attribute of your Inline Class:

 class MyInline(StackedInline): model = MyModel classes = ('collapse open',) inline_classes = ('collapse open',) 

This did not seem to work in 2.3.5 (I had to upgrade to 2.3.7 to make it work). And since it is unclear, “classes” are a property of a collection of strings that can be collapsed or expanded, while “inline_classes” is a property of the strings themselves.

source: http://readthedocs.org/docs/django-grappelli/en/latest/customization.html#collapsibles

+15
source

Probably the easiest way to do this is to inject some jQuery code into a custom template for this change model.

0
source

All Articles