Skip to main content

A filter backend for Django REST framework.

Project description

rest-filters

PyPI version

rest-filters is an extension for Django REST Framework that parses query parameters and constructs the corresponding QuerySet objects.

See full documentation at: https://rest-filters.readthedocs.io/

Installation

Use your favorite Python package manager to install rest-filters:

pip install rest-filters

rest-filters supports Django 4.2 and Django 5.2, with REST framework 3.14 and above.

rest-filters uses semantic versioning: https://semver.org

A basic example

Here is a basic FilterSet declaration that allows filtering users by username, company, and creation date.

Check out getting started guide for more details.

from rest_filters import Filter, FilterSet
from rest_framework import serializers


class UserFilterSet(FilterSet[User]):
    username = Filter(
        serializers.CharField(min_length=2, required=False),
        lookup="icontains",
    )
    company = Filter(
        namespace=True,
        children=[
            Filter(
                serializers.IntegerField(min_value=1, required=False),
                lookup="id",
            ),
            Filter(
                serializers.CharField(min_length=2, required=False),
                lookup="name__icontains",
            ),
        ],
    )
    created = Filter(
        serializers.DateTimeField(required=False),
        namespace=True,
        children=[
            Filter(lookup="gte"),
            Filter(lookup="lte"),
        ],
    )

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

rest_filters-0.4.2.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rest_filters-0.4.2-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file rest_filters-0.4.2.tar.gz.

File metadata

  • Download URL: rest_filters-0.4.2.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.8

File hashes

Hashes for rest_filters-0.4.2.tar.gz
Algorithm Hash digest
SHA256 de8bfb5583ea9f4d29c9bf3bceb9749a335c053ba85eaf697f9fa9da139e4459
MD5 29d25e59382b9f6877e6397fe48785dd
BLAKE2b-256 564001004136ea533fdf995200010b72f287c601c6714ffba4a681b7c11b29e7

See more details on using hashes here.

File details

Details for the file rest_filters-0.4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for rest_filters-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c72cc0b4af840d29976847e8c9ac3df28aee63cedaad43e60ca2f3440ad75c3f
MD5 f91034fdc9a8e1c562fbb5ebd7bf0e9f
BLAKE2b-256 c2dbb003571fcf1e18fb468017854f7c65f42d6cbb59ccf575b0ccae1e9576e1

See more details on using hashes here.

Supported by

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