Adding Search to the List Screen
You set it with a tuple containing the names of fields to be used for constructing a search query in the database. Anything the user types in the search box is used in an
OR clause of the fields filtering the
QuerySet. By default, each search parameter is surrounded by percent signs (
%), meaning that if you search for
r, then any word with an
r inside will appear in the results.
Here you can see
core/admin.py is being edited to change this. In this code, searching is based on
__startswith modifier restricts the search to last names that begin with the search parameter. Searching on
R provides the following results.
01:25 More details can be found in the documentation. Customization of the admin interface isn’t limited to how existing data is presented. It’s also possible to change how data is created and edited, and that’s what’s covered in the next section.
Become a Member to join the conversation.