Custom Filters
Explore how to implement custom filters in the Django Admin interface. Learn to create filter classes by extending SimpleListFilter, define filter options with lookups, and filter queryset results. This lesson helps you tailor data views with custom filtering for better administration.
We'll cover the following...
We'll cover the following...
Adding the custom filter
It is possible to create your own methods to filter data. Take a look at the following interface:
Custom filter options.
As you can see there is a new filter option: By published questions. It has two options: published questions or unpublished questions.
To do that you need to write a class that inherits from
django.contrib.admin.SimpleListFilter
class QuestionPublishedListFilter(admin.SimpleListFilter):
# Human-readable title which will be displayed in the
...