Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django admin : Expand all the entries in stackedinline by default

In my django application, I am using an admin interface to see all the products and each product can have several images. I have stacked the images into the Product Page using the below code

class ProductImage_Inline(admin.StackedInline):
    model = ProductImage
    extra = 3

    formfield_overrides = {
        ImageWithThumbnailField : {'widget' : AdminImageWithThumbnailWidget},

By default, in the Product Admin page I can't see all the images because all the entires in the StackedInline are collapsed by default. I have to manually click on each of them to expand so as to see the image.

How can I expand all the entries in a StackedInline by default?

P.S : I am using Grappelli theme and suspect that it is collapsing them by default

like image 278
Srihari Avatar asked Nov 23 '11 09:11

Srihari


1 Answers

I realize that this is a bit late, but, as of Grappelli 2.3.7, you can now easily do what your 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 didn't seem to work in 2.3.5 (I had to upgrade to 2.3.7 to make it work). And since it isn't clear, 'classes' is the property of the collection of inlines, which can be collapsed or expanded, whereas 'inline_classes' is a property of the inlines themselves.

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

like image 129
B Robster Avatar answered Sep 30 '22 17:09

B Robster