Use dropdowns in Django admin list filter
Project description
django-unfold-admin-list-filter-dropdown
[!NOTE]
This version is compatible with django-unfold.
A Django admin filter implementation that renders as a dropdown.
If you have more than ten values for a field that you want to filter by in Django admin, the filtering sidebar gets long, cluttered and hard to use.
This app contains the DropdownFilter
class that renders as a drop-down in the
filtering sidebar to avoid this problem.
Usage
Install:
pip install django-unfold-admin-list-filter-dropdown
Enable in settings.py
:
INSTALLED_APPS = (
...
'django_unfold_admin_listfilter_dropdown',
...
)
Use in admin.py
:
from django_admin_listfilter_dropdown.filters import DropdownFilter, RelatedDropdownFilter, ChoiceDropdownFilter
class EntityAdmin(admin.ModelAdmin):
...
list_filter = (
# for ordinary fields
('a_charfield', DropdownFilter),
# for choice fields
('a_choicefield', ChoiceDropdownFilter),
# for related fields
('a_foreignkey_field', RelatedDropdownFilter),
)
Example of a custom filter that uses the provided template:
class CustomFilter(SimpleListFilter):
template = 'django_unfold_admin_listfilter_dropdown/dropdown_filter.html'
def lookups(self, request, model_admin):
...
def queryset(self, request, queryset):
...
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django_unfold_admin_list_filter_dropdown-1.0.11.tar.gz
.
File metadata
- Download URL: django_unfold_admin_list_filter_dropdown-1.0.11.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddfa6d3be1bc41a5f58c864701ddd134e2b889ce29fbefcb8c60d1f739447dbc |
|
MD5 | 47a52cb05e0e4072008d89e531d36ffe |
|
BLAKE2b-256 | 1cd71c8b87be6df0ac71c97c7479e5495adb300b238ed46a2d6fa61eed8953fe |
File details
Details for the file django_unfold_admin_list_filter_dropdown-1.0.11-py3-none-any.whl
.
File metadata
- Download URL: django_unfold_admin_list_filter_dropdown-1.0.11-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1efbbb19c411cad410997d254c3657fa9b9fd9019cbad88564961860d0d9bbf5 |
|
MD5 | 011d9fb7de6c0524045c44cca39e340f |
|
BLAKE2b-256 | c17bbf72fc128e185a8a7c4f2274f857badf72d5b3a1ad33fa865337110216f2 |