+
+
+class YesNoFilter(admin.SimpleListFilter):
+ def lookups(self, request, model_admin):
+ return (
+ ('yes', 'Tak'),
+ ('no', 'Nie'),
+ )
+
+ def queryset(self, request, queryset):
+ if self.value() == 'yes':
+ return queryset.filter(self.q)
+ elif self.value() == 'no':
+ return queryset.exclude(self.q)
+
+
+def is_ajax(request):
+ return request.headers.get('x-requested-with') == 'XMLHttpRequest'