• Stars
    star
    306
  • Rank 131,909 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created over 7 years ago
  • Updated 24 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Use dropdowns in Django admin list filter

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, 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_admin_listfilter_dropdown/dropdown_filter.html'

    def lookups(self, request, model_admin):
        ...

    def queryset(self, request, queryset):
        ...

Example

Here's what it looks like:

Screenshot of dropdown admin filter

Credits

Based on this StackOverflow question and code from FeinCMS.

More Repositories

1

docker-postgresql-multiple-databases

Using multiple databases with the official PostgreSQL Docker image
Shell
656
star
2

winforms-mvp

Windows Forms example of the Passive View variant of the Model-View-Presenter pattern
C#
209
star
3

git-svn-bridge

Instructions, scripts and utility programs for synchronizing/mirroring changes between git and Subversion
C#
120
star
4

git-mirror

Scripts for setting up and synchronizing two-way mirroring between two Git repositories
Shell
78
star
5

burp-suite-http-proxy-history-converter

Python script that converts Burp Suite HTTP proxy history files to CSV or HTML
Python
77
star
6

ask-jira

Python app that uses the Jira API for aggregate and complex tasks and reports
Python
41
star
7

migrate-imap-account-to-gmail

Migrate mail from IMAP server account to GMail account
Python
35
star
8

ubuntu-old-kernel-cleanup

Script that helps to remove unused kernels from an Ubuntu (and possibly also Debian) Linux system
Python
21
star
9

django-commands

Management commands for Django: clear database, backup database, load database from backup, clear cache.
Python
17
star
10

burp-suite-http-proxy-history-viewer

Burp Suite HTTP proxy history viewer
Java
15
star
11

flag-set-cpp

flag_set is a type-safe class for using enums as flags in C++
C++
10
star
12

xml-xslt-xsl-fo-dotnet

Example of generating PDF documents in .NET with XML, XSLT, XSL-FO and FO.NET
C#
10
star
13

django-deploy

Automatic remote deployment of Django projects with Fabric as well as environment setup and development process guidelines.
Python
8
star
14

remote-ejb-injection

Sample project for demonstrating inter-artifact communication between artifacts deployed inside the same Java EE application server
Java
6
star
15

vaadin-javaee-jaas-example

Example Vaadin 8 Java EE application that demonstrates how to authenticate and authorize users using JAAS and Vaadin CDI add-on, login form and view navigator
Java
6
star
16

mono-static-linking

Small example of static linking C libraries into applications with Mono
C#
5
star
17

datamapper-cpp

datamapper-cpp is an object-relational mapper for C++ and SQLite
C++
5
star
18

dbc-cpp

Lightweight database access library for C++ with JDBC-like ResultSet interface. Only SQLite driver implemented for now.
C++
4
star
19

plugit

A framework for installing applications. See http://wiki.python.org/moin/ApplicationInfrastructure for specifics.
Python
4
star
20

debugging-cgi-applications-with-gdb

How to debug CGI applications with GDB
C
4
star
21

util-cpp

General utilities useful in C++ development: release assert, lightweight scoped pointer that accepts a deleter and does not depend on Boost, disable copy etc.
C++
3
star
22

docker-python-nodejs-google-chrome

Docker image with latest Python 3, Node.js 12 and stable Google Chrome - and ack
Dockerfile
3
star
23

local-ejb-injection

Sample project demonstrating packaging EJB JARs and WARs into EAR
Java
3
star
24

vaadin-javaee-clinic-patient-queue-example

An example clinic patient queue application using server push, Vaadin 8 and Java EE 8
Java
3
star
25

cve_tracker

Python CVE tracker
Python
2
star
26

tincan

tincan is a C++ ORM for SQLite and a serializer to/from XML that is built on top of a generic object mapping core
C++
2
star
27

docker-cmake-gtest-valgrind-ubuntu

Docker image with CMake, Google Test, Valgrind and C++ build tools
Dockerfile
2
star
28

dotfiles

My dotfiles (vim, bash etc)
Python
2
star
29

docker-python-selenium-xvfb

Dockerfile for building MRTS/PYTHON-SELENIUM-XVFB image with Python, Selenium, Chrome, XVFB, Requests and Records with PostgreSQL and Oracle support
Python
2
star
30

docker-python-spatialite

Docker image with latest Python 3, SpatiaLite and SpatiaLite dependencies (PROJ.4, GEOS, GDAL) suitable for GeoDjango
Dockerfile
2
star
31

validate-git-commit-authors-against-gitlab

Validate Git commit authors against GitLab group members during pushes to Git repository
Python
2
star
32

qparams

Add add_query_params() to urlparse and urllib.parse (details at the homepage URL below)
Python
2
star
33

boost-bootstrap

Script that bootstraps Boost
C++
1
star
34

jira-warden

Python app for tending for JIRA Software issues and sprint boards
Python
1
star
35

algorithm-utils-cpp

High-level utility wrappers around standard algorithms and Boost to make functional programming in C++ easier.
C++
1
star
36

profile

Profiling experiments to use /fastcap optimally in Windows CE
C
1
star
37

docker-java-selenium-xvfb

Dockerfile for building MRTS/JAVA-SELENIUM-XVFB image with OpenJDK, Selenium, Chrome, XVFB and Oracle JDBC support
Java
1
star
38

foodbank-campaign

FoodBank campaing management app built with Django
Python
1
star
39

win32-asyncconnect

Asynchronous host name lookup and socket connection example with win32 Winsock API.
C++
1
star
40

currency-rate-monitor

Python app for monitoring currency rates and configured amount value changes. Sends statistics and a graph with rate history to configured email. Fetches rates from TransferWise.
Python
1
star
41

test-cpp

A lightweight template-based testing framework for C++ that integrates well with Visual Studio.
C++
1
star