Registry / web-framework / django-admin-list-filter-dropdown

django-admin-list-filter-dropdown

JSON →
library1.0.3pypypi✓ verified 24d ago

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-dropdown
INSTALL
IMPORT
SIG · DJANGO-ADMIN-LIST-
D
django-admin-list-filter-dropdown
web-frameworkpythonv1.0.3
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DropdownFilter
from django_admin_listfilter_dropdown.filters import DropdownFilter
from django_admin_listfilter_dropdown import DropdownFilter

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.

# settings.py INSTALLED_APPS = [ # ... other apps 'django_admin_listfilter_dropdown', # ... ] # admin.py from django.contrib import admin from django.db import models # For example model from django_admin_listfilter_dropdown.filters import DropdownFilter, ChoiceDropdownFilter, RelatedDropdownFilter # Example Models class Category(models.Model): name = models.CharField(max_length=100) def __str__(self): return self.name class Product(models.Model): STATUS_CHOICES = [ ('in_stock', 'In Stock'), ('out_of_stock', 'Out of Stock'), ('coming_soon', 'Coming Soon'), ] name = models.CharField(max_length=100) status = models.CharField(max_length=20, choices=STATUS_CHOICES) category = models.ForeignKey(Category, on_delete=models.CASCADE) is_active = models.BooleanField(default=True) def __str__(self): return self.name @admin.register(Product) class ProductAdmin(admin.ModelAdmin): list_display = ('name', 'status', 'category', 'is_active') list_filter = ( ('status', ChoiceDropdownFilter), # For fields with choices ('category', RelatedDropdownFilter), # For foreign key fields ('is_active', DropdownFilter), # For boolean fields, or custom SimpleListFilter ) @admin.register(Category) class CategoryAdmin(admin.ModelAdmin): list_display = ('name',)
Debug
Known issues
gotchaThe library has not seen a new release since October 2019. While it generally works with modern Django versions, explicit compatibility with Django 4.x or 5.x is not guaranteed and may require manual testing or minor template adjustments. Consider testing thoroughly on newer Django projects.
fix
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.
affects: Django >= 3.0
gotchaThe dropdown filters typically only render as a dropdown if there are a sufficient number of distinct options (e.g., more than 2 or 3). If fewer options exist, Django's default list filter rendering (as a simple list) will likely be used instead.
fix
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.
affects: All versions
gotchaThis library does not natively provide search/autocomplete functionality within the dropdowns. For filtering very large datasets, users might find it cumbersome to scroll through a long list.
fix
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.
affects: All versions
gotchaForgetting to add `'django_admin_listfilter_dropdown'` to your `INSTALLED_APPS` in `settings.py` is a common mistake that will prevent the custom dropdown filters from being recognized and applied in the Django admin.
fix
Always ensure `INSTALLED_APPS` includes `'django_admin_listfilter_dropdown'`.
affects: All versions
Upgrade
Version history
1.0.3latest on PyPI · released Oct 14, 2019
Audit
Dependencies
DjangorequiredCore framework dependency; integrates with Django's admin interface.
Agent activity
7 hits · last 30 days
node
6
Resources
django-admin-list-filter-dropdown — pip install django-admin-list-filter-dropdown · libregistry