Skip to main content

Use dropdowns in Django admin list filter

Project description

django-unfold-admin-list-filter-dropdown

PyPI version

[!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

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file django_unfold_admin_list_filter_dropdown-1.0.12.tar.gz.

File metadata

File hashes

Hashes for django_unfold_admin_list_filter_dropdown-1.0.12.tar.gz
Algorithm Hash digest
SHA256 d52d2d25863424bdef3c09449e5e1d1a404fb36c59a49c6091143b1e13f63769
MD5 391ccc41e506ddde17f4897aabfdf380
BLAKE2b-256 ce5e28b831dadeb843ca6c30e2e954598c877de4b6930b06e29fef2b51886fa8

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_unfold_admin_list_filter_dropdown-1.0.12.tar.gz:

Publisher: publish.yml on francoborrelli/django-unfold-admin-list-filter-dropdown

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_unfold_admin_list_filter_dropdown-1.0.12-py3-none-any.whl.

File metadata

File hashes

Hashes for django_unfold_admin_list_filter_dropdown-1.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 fd1f6311a26daa524ad1185e66178f0aedea217ecb2a9aaf75309fd0dd8f76a0
MD5 a0273210b6478bcac30752f4a9c55ac8
BLAKE2b-256 a837554f8e217c5297cfc804268e07c352dbafcd047ecd4a4b5f55241e9087a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_unfold_admin_list_filter_dropdown-1.0.12-py3-none-any.whl:

Publisher: publish.yml on francoborrelli/django-unfold-admin-list-filter-dropdown

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page