Skip to main content

A collection of addons for django-filter

Project description

django-filter-addons Build Status

A collection of addons for django-filter

Installation

Install the package from PyPi:

pip install django-filter-addons

Usage

Implement case-insensitivity on queryset ordering:

from django.contrib.auth.models import User
from django.db.models.functions import Lower

from django_filters.filters import CharFilter
from django_filters.filterset import FilterSet

from django_filters_addons.filters import OrderingFilter

class UserFilter(FilterSet):
    account = CharFilter(field_name='username')
    sort = OrderingFilter(
        fields={'username': 'account', 'first_name': 'first_name', 'last_name': 'last_name', 'email': 'email'},
        field_cases={'username': Lower, 'email': Lower},
    )

    class Meta:
        model = User
        fields = ('first_name', 'last_name', 'email')

License

django-filter-addons is released under the MIT license.

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-filter-addons-0.2.0.tar.gz (2.2 kB view hashes)

Uploaded source

Built Distribution

Supported by

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