Skip to main content

A generic filter for the django-admin-page based on django-filter.

Project description

https://api.travis-ci.org/thomst/django-admin-filter.svg?branch=master https://coveralls.io/repos/github/thomst/django-admin-filter/badge.svg?branch=master python: 3.4, 3.5, 3.6, 3.7, 3.8 django: 1.11, 2.0, 2.1, 2.2, 3.0

Description

Django-admin-filter is a generic form-based filter for the django-admin-page. It is based on django-filter. It provides a flexible and direct way to filter the items of your changelist and to save and reuse your queries.

Installation

Install from pypi.org:

pip install django-admin-filter

Configuration

There are three things you need to do to use a custom filter-form for your model in your admin changelist:

Add django_admin_filter to your INSTALLED_APPS:

INSTALLED_APPS = [
   'django_admin_filter',
   ...
]

Add the CustomFilter to the list_filter of your ModelAdmin:

from django_admin_filter.filters import CustomFilter

class MyAdmin(admin.ModelAdmin):
   list_filter = [CustomFilter, ...]
   ...

And setup the filter-class you want to use with your model. This works exactly as described in the django-filter-docs. But to use your filter-class with the django-admin-filter there is one thing to mind: Instead of subclass django_filters.FilterSet:

import django_filters

class MyFilter(django_filters.FilterSet):
   ...

use the AdminFilterSet:

from django_admin_filter.filterset import AdminFilterSet

class MyFilter(AdminFilterSet):
   ...

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

django-admin-filter-0.2.tar.gz (9.6 kB view hashes)

Uploaded Source

Built Distribution

django_admin_filter-0.2-py3-none-any.whl (12.4 kB view hashes)

Uploaded Python 3

Supported by

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