Search⌘ K
AI Features

Filtering and Searching

Explore how to add filtering and searching capabilities in the Django Admin interface. Learn to use list_filter to narrow data by specific fields including foreign keys and search_fields to enable searching across multiple model fields. This lesson equips you to manage and access data more efficiently within your Django project.

We'll cover the following...

Filtering

To add a filter, you can use the list_filter instruction. For instance, you can use this instruction to filter results by Author in your Question change page, so that, when selected, only the questions related to the specific author are displayed.

list_filter = ('refAuthor',)

You will find a display like the one shown below. From the right side of the display page, you can select the specific author to filter results accordingly.

Filtering the results by Author in Question change page.
Filtering the results by Author in Question change page.

As can be seen, you now ...