+
+
+class YesNoFilter(admin.SimpleListFilter):
+ def lookups(self, request, model_admin):
+ return (
+ ('yes', _('Yes')),
+ ('no', _('No')),
+ )
+
+ def queryset(self, request, queryset):
+ if self.value() == 'yes':
+ return queryset.filter(self.q)
+ elif self.value() == 'no':
+ return queryset.exclude(self.q)