Re: SimpleListFilter is giving "NotImplementedError"
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? '=='
Cheers
Tom
--
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