Thursday, November 22, 2012

Re: SimpleListFilter is giving "NotImplementedError"

On Fri, Nov 23, 2012 at 12:06 PM, Tom Evans <tevans.uk@googlemail.com> wrote:
> On Thu, Nov 22, 2012 at 11:21 PM, Lachlan Musicman <datakid@gmail.com> wrote:
>> Hola,
>>
>> After successfully implementing two range based filters using the admin's
>> list_filter docs:
>> PATH/ref/contrib/admin/index.html#django.contrib.admin.ModelAdmin.list_filter
>>
>> I've added one more filter, but now I'm getting a NotImplementedError and I
>> can't see what I've done wrong. The model has a field called "island" and I
>> would like to distinguish between the main island and the "outer islands"
>> (all the rest). Note the commented out returns - me trying to find any
>> subtle changes to fix this:
>>
>> class IslandFilter(admin.SimpleListFilter):
>> title = 'islands'
>> parameter_name = 'island'
>>
>> def lookup(self, request, model_admin):
>> return (
>> ('tarawa', 'Tarawa'),
>> ('outer-islands', 'Outer Islands'),
>> )
>>
>> def queryset(self, request, queryset):
>> if self.value == 'tarawa':
>> return queryset.filter(island=='Tarawa')
>
> Is it that typo? '=='

Tom, thanks for your reply. No, that's not a typo, as noted it's an
attempt to see what the problem might be. I've just changed the code
back to the original code (below) to test again, and it's still
failing, with the same error

return queryset.filter(island__exact='Tarawa')
return queryset.exclude(island__exact='Tarawa')

Cheers
L.

--
...we look at the present day through a rear-view mirror. This is
something Marshall McLuhan said back in the Sixties, when the world
was in the grip of authentic-seeming future narratives. He said, "We
look at the present through a rear-view mirror. We march backwards
into the future."

http://www.warrenellis.com/?p=14314

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate