Skip to content

Commit

Permalink
Minimal test case for SimpleListFilter (jazzband#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmihelac committed Dec 5, 2023
1 parent b9c1f3e commit 9c3f5d9
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion sample_project/samples/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,33 @@
CustomWidget, CustomWidgetComponent, BackwardCompatibleWidget)


admin.site.register(Category, SortableAdmin)
class DecadeBornListFilter(admin.SimpleListFilter):
# dummy filter
# https://docs.djangoproject.com/en/5.0/ref/contrib/admin/filters/#using-a-simplelistfilter
title = 'decade born'
parameter_name = 'decade'

def lookups(self, request, model_admin):
return (
('80s', 'in the eighties'),
('90s', 'in the nineties'),
)

def queryset(self, request, queryset):
return queryset


class CategoryAdmin(SortableAdmin):
list_filter = (DecadeBornListFilter,)

# workaround
# def get_querystring_filters(self, request):
# filters = super().get_querystring_filters(request)
# filters.pop("decade", None)
# return filters


admin.site.register(Category, CategoryAdmin)


class ComponentInline(SortableStackedInline):
Expand Down

0 comments on commit 9c3f5d9

Please sign in to comment.