Can admin page filter can search by text?

Hello! I have a foreign key field staff_id and when I try to add a filter for it, it will display a long list and it is hard to search.

Is there any way to change it to a text search? Many thanks.

Welcome @Kiawaik !

Yes, there are ways of implementing the Select2 widget as a filter. However, there isn’t anything built-in and may take some effort on your part to build from existing options.

See the blog post at Mastering Django Admin Part 2: Improving List Filters with Custom Select2 Integration | by Sudip Parajuli | Python in Plain English as one implementation.

Other resources include django-admin-autocomplete-filter · PyPI (Note: This is sufficiently old that it might not work out-of-the-box, but you should be able to create your own copy and update it to get it to work.)

Also see How can we use autocomplete dropdown (select2) for filters in Django Admin for normal fields?

Many thanks! It works using the Custom Select2! :grinning: