Using SimpleListFilter for Easy Implementation
from django.contrib import admin
class TicketStatusListFilter(admin.SimpleListFilter):
title = 'Status'
parameter_name = 'status_set'
def lookups(self, request, model_admin):
return (
('incomplete', 'Incomplete'),
('completed', 'Completed'),
)
def queryset(self, request, queryset):
if self.value() == 'incomplete':
return queryset.exclude(status='completed')
if self.value() == 'completed':
return queryset.filter(status='completed')
class TicketAdmin(admin.ModelAdmin):
list_filter = (TicketStatusListFilter,)
Comments