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), lookup="icontains")
    company = Filter(
        namespace=True,
        children=[
            Filter(
                serializers.IntegerField(min_value=1),
                lookup="id",
            ),
            Filter(
                serializers.CharField(min_length=2),
                lookup="name__icontains",
                param="name",
            ),
        ],
    )
    created = Filter(
        serializers.DateTimeField(),
        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.5.0.tar.gz (15.0 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.5.0-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for rest_filters-0.5.0.tar.gz
Algorithm Hash digest
SHA256 3b13af0e58c130ffce6e0b590302848cdd8509a8ed7d2854e76dcd9c063da2bc
MD5 c3a315a997498a8e2b75e4cf5231ee5c
BLAKE2b-256 d51fac1b4e604c1d0bf88220117853951d6e665982a3476a80265dfba5da82a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rest_filters-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94ca815b9c1162a7dab4ccc05701312fdb13c9e3e720909a51fa69accff12503
MD5 5a04cd9fe94366b1cf746083d0ee87fd
BLAKE2b-256 e3654e03323e58b44dc2c0a3e2b23472e92dbb3ee9d03d0a29b78307efdbc5b9

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