Skip to content

hactar-is/django-admin-list-filter-dropdown

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-admin-list-filter-dropdown

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-admin-list-filter-dropdown

Enable in settings.py:

INSTALLED_APPS = (
    ...
    'django_admin_listfilter_dropdown',
    ...
)

Use in admin.py:

from django_admin_listfilter_dropdown.filters import DropdownFilter, RelatedDropdownFilter

class EntityAdmin(admin.ModelAdmin):
    ...
    list_filter = (
        # for ordinary fields
        ('a_charfield', DropdownFilter),
        # for related fields
        ('a_foreignkey_field', RelatedDropdownFilter),
    )

Example

Here's what it looks like:

Screenshot of dropdown admin filter

Credits

Based on this StackOverflow question and code from FeinCMS.

About

Use dropdowns in Django admin list filter

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 67.0%
  • HTML 33.0%