Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

A Django app to add a Multiple Choice List Filter to the admin interface.

Project description

Django Admin Multiple Choice List Filter

The SimpleListFilter that ships with Django only allows you to filter on one
option at a time. MultipleChoiceListFilter extends SimpleListFilter to allow you
to filter on multiple options.

Getting started

Install via pip::

pip install django-admin-multiple-choice-list-filter


# project/


As an example, let's say you had a ``shop`` app. In that app you have an ``Order`` model with a ``status`` field that has limited choices::

# shop/

from django.db import models

class Statuses(object):

(RECEIVED, 'Received'),
(PROCESSING, 'Processing'),
(SHIPPED, 'Shipped'),
(CLOSED, 'Closed'),

class Order(models.Model):
status = models.IntegerField(

Then, in your app's

# shop/

from django.contrib import admin

from django_admin_multiple_choice_list_filter.list_filters import MultipleChoiceListFilter

from .models import Order, Statuses

class StatusListFilter(MultipleChoiceListFilter):
title = 'Status'
parameter_name = 'status__in'

def lookups(self, request, model_admin):
return Statuses.CHOICES

class OrderAdmin(admin.ModelAdmin):
list_display = ('status',)
list_filter = (StatusListFilter,), OrderAdmin)

Your admin area will now display the MultipleChoiceListFilter. It looks a lot like the
SimpleListFilter, except there is now an additional link next to each choice. Use these
links to include or exclude the choice from the results. You can mix and match any
combination you like.

.. image::

You can override the default template in one of two ways.

1. Override the template:
The default template location is ``django_admin_multiple_choice_list_filter/filter.html``
2. Set the template name in your subclass of MultipleChoiceListFilter, e.g.::

# shop/

class StatusListFilter(MultipleChoiceListFilter):
template = 'path/to/your/template.html'

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-admin-multiple-choice-list-filter, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size django_admin_multiple_choice_list_filter-0.1.1-py2-none-any.whl (6.8 kB) File type Wheel Python version py2 Upload date Hashes View
Filename, size django-admin-multiple-choice-list-filter-0.1.1.tar.gz (4.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page