Customizing Django Admin search
October 11, 2023
Steps to override search form in Django admin:
- Add custom search form
- Override ChangeList and implement get_filters_params() so that it excludes the new search form fields (otherwise filters don’t work)
- Override search_form.html because it has hardcoded single search form field
- Override change_list.html to customize styling (e.g. with flexbox)
- If search form has many fields, split fields to multiple divs by using cl.search_form.visible_fields|slice:“0:5” and rendering fields manually