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.7.0.tar.gz (16.2 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.7.0-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rest_filters-0.7.0.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for rest_filters-0.7.0.tar.gz
Algorithm Hash digest
SHA256 d7f68989d838fb5f01ba8040218bf0a86d7926fd29efd84bfae5c234c6c77490
MD5 e9664950bb94d47a47ab8bc38c4c1cc2
BLAKE2b-256 c42f58e6431caa9a832c025a3e1f54bc1877135f2103afe627671771b33f59f8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rest_filters-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for rest_filters-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0eb81d0232df9e7d21e251550990e8f0af4e3bc897c873fa7aa1c170f93826fd
MD5 b5e4366cfb7ce91afe40b84bac70b42e
BLAKE2b-256 469339393305f38d587ee48bfc6d822d532c6be3a22532ec02d6e63b0fa1b2c1

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