Skip to main content
========================================
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

Add to INSTALLED_APPS in settings.py::

# project/settings.py

INSTALLED_APPS = [
...
'django_admin_multiple_choice_list_filter',
]

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/models.py

from django.db import models


class Statuses(object):
RECEIVED, PROCESSING, SHIPPED, CLOSED = range(0, 4)

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


class Order(models.Model):
status = models.IntegerField(
choices=Statuses.CHOICES,
default=Statuses.RECEIVED,
)

Then, in your app's admin.py::

# shop/admin.py

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,)

admin.site.register(Order, 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:: https://raw.githubusercontent.com/ctxis/django-admin-multiple-choice-list-filter/master/django-admin-multiple-choice-list-filter.png

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

1. Override the template: https://docs.djangoproject.com/en/2.0/howto/overriding-templates/.
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/admin.py
...

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


Metadata

Release files for django-admin-multiple-choice-list-filter 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-admin-multiple-choice-list-filter 0.1.1
File Size Uploaded Provenance Actions
django-admin-multiple-choice-list-filter-0.1.1.tar.gz 4.5 kB Without provenance Details for django-admin-multiple-choice-list-filter-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-admin-multiple-choice-list-filter 0.1.1
File Interpreter ABI Platform Actions
django_admin_multiple_choice_list_filter-0.1.1-py2-none-any.whl Python 2 none any Details for django_admin_multiple_choice_list_filter-0.1.1-py2-none-any.whl

Total release size: 11.3 kB

Release files / django-admin-multiple-choice-list-filter-0.1.1.tar.gz

Download URL django-admin-multiple-choice-list-filter-0.1.1.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a5b82682ff752cf74bbc4fa3d562c99b9f9f80389961017e1ac63e08f22d8b9f
BLAKE2b-256 checksum
How to use checksums
865259664dade0552d6e2c76b5b1e94ea73b5390e8c4dcdf14d368f805a28ee4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_admin_multiple_choice_list_filter-0.1.1-py2-none-any.whl

Download URL django_admin_multiple_choice_list_filter-0.1.1-py2-none-any.whl
Size 6.8 kB
Tags Python 2
SHA-256 checksum
How to use checksums
eab2ad5fad6df8ed8436cb6c1d0e67863453a9d30282b7fdcb7e45b2eb37ab6f
BLAKE2b-256 checksum
How to use checksums
99afa15bb1c2ab4314f7c1cb4b65f1f9713370205bc0bede9fa14818681eb1df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-admin-multiple-choice-list-filter 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page