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')
            #return queryset.filter(island__exact='Tarawa')
        else:
            return queryset.exclude(island=='Tarawa')
            #return queryset.exclude(island__exact='Tarawa')


class ApplicantAdmin(admin.ModelAdmin):
     list_filter = ('gender', 'disability', MathTestFilter,
EnglishTestFilter, IslandFilter,'successful', 'applied_for', 'eligibility')

Can anyone see what I've done wrong please?


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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to