tejinderss
tejinderss

Reputation: 1652

Django 1.4 SimpleListFilter 'selected' option issue

I have written a SimpleListFilter, here is the code: http://dpaste.com/639578/

It displays in the admin list properly, but i am having an issue, The selected option does not get highlighted in the custom filter. Only 'All' highlights but not the custom options. Here is the screenshot to illustrate that:

http://imgur.com/IyrYk


If anybody interested in this, here is the follow up: https://code.djangoproject.com/ticket/17091

Upvotes: 3

Views: 1178

Answers (2)

Grimalt Santiago
Grimalt Santiago

Reputation: 141

For this reason I implemented a 'choices' function:

def choices(self, cl):
    lookup_choices = [('',_('All'))] + self.lookup_choices
    for lookup, title in lookup_choices:
        yield {
            'selected': self.value() == str(lookup),
            'query_string': cl.get_query_string({self.parameter_name: lookup,}, []),
            'display': title,
        }

Upvotes: 2

datakid
datakid

Reputation: 2702

Offtopic: re the drop down menus, I was also interested. A quick search shows that there is no built in ability to do this, but there are a couple of easy solutions: DIY or use products like Grappelli or FeinCMS.

Upvotes: 0

Related Questions