Custom Filters

Learn how to add custom filters for your models.

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.
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
    # right
...