django-admin-list-filter-dropdown is a Python library that enhances the Django administration interface by converting default list filters into dropdowns. This improves usability and reduces clutter in the sidebar, especially when a filter has numerous options. The current version is 1.0.3, released in 2019, suggesting a stable but less actively maintained project.
pip install django-admin-list-filter-dropdownVerified import paths — ran on the pinned version, not inferred.
First, add `django_admin_listfilter_dropdown` to your `INSTALLED_APPS`. Then, in your `admin.py`, import the desired filter classes (e.g., `DropdownFilter`, `ChoiceDropdownFilter`, `RelatedDropdownFilter`) and use them within the `list_filter` tuple of your `ModelAdmin` class. This example demonstrates how to apply dropdown filters to a choice field, a foreign key field, and a boolean field.
Thoroughly test on your target Django version. If issues arise, investigate the Django admin templates for breaking changes that might affect the custom filter rendering. Forks or alternative packages (like django-unfold-admin-list-filter-dropdown) might offer better compatibility with newer Django admin themes.
This is intended behavior to avoid unnecessary dropdowns. If you strictly require a dropdown for fewer options, you might need to override the filter's `template` attribute with a custom template that forces dropdown rendering, or extend the filter logic.
For searchable dropdowns, consider integrating with another library like `django-admin-autocomplete-list-filter` (though deprecated, it shows the concept), or `django-admin-searchable-dropdown`, or implement custom JavaScript/Ajax for autocomplete functionality within your Django admin.
Always ensure `INSTALLED_APPS` includes `'django_admin_listfilter_dropdown'`.