Skip to main content

Construct arbitrarily complex Django "Q" filters from flat data, such as query parameters.

Project description

https://travis-ci.org/bennullgraham/filternaut.svg?branch=master Code Health

Filternaut is a simple library which generates arbitrarily complex Django Q-objects from simple data. It fits nicely into situations where users provide data which you want to filter a queryset with.

Filternaut is indirectly a collection of fields, but it differs from Django forms in that you specify the logical relationships between fields, as well their names and types.

Filternaut is similar to Django Filters, but does not provide any machinery for rendering a user interface and does not inspect your models to autogenerate filters. However, Django Filters chains many calls to .filter() which means OR-like behaviour with more than one join. Filternaut supports either behaviour.

Quickstart

# filters are combined using logical operators
filters = (
    DateTimeFilter('created_date', lookups=['lt', 'gt']) &
    CharFilter('username', lookups=['icontains']))

# they can read their values from anything dict-like
filters.parse(request.GET)

# and have a form-like 'validity pattern'.
if filters.valid:
    queryset = queryset.filter(filters.Q)
else:
    raise HttpResponseBadRequest(json.dumps(filters.errors))

Installation

$ pip install django-filternaut

Filternaut is compatible with:

  • Python 3

  • Django 2.2 and 3.0

  • Django REST Framework 3.11 (optional)

Python 2.7 support is still in the codebase but no longer tested. You are welcome to try your luck.

Documentation

See https://filternaut.readthedocs.org for full documentation.

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-filternaut-0.0.13.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

django_filternaut-0.0.13-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file django-filternaut-0.0.13.tar.gz.

File metadata

  • Download URL: django-filternaut-0.0.13.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.12.4 setuptools/33.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.5.3rc1

File hashes

Hashes for django-filternaut-0.0.13.tar.gz
Algorithm Hash digest
SHA256 1b3624a9d139809f2f8d0a54b6adf4624e565820eb2708c723554dd10c2b282b
MD5 35ea9bd96cad4f403bc4f41963cdddd3
BLAKE2b-256 1dbc285e09f722de7fcc238b2c9e2938f3f85e1e0518ea83dfd0aaa3b73dfacb

See more details on using hashes here.

File details

Details for the file django_filternaut-0.0.13-py3-none-any.whl.

File metadata

  • Download URL: django_filternaut-0.0.13-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.12.4 setuptools/33.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.5.3rc1

File hashes

Hashes for django_filternaut-0.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 cd4101694947997a714a43907432a52d3c01f08328b9340765274d1d895774ef
MD5 2178e67610f0b8e7dd71ec37a89a8469
BLAKE2b-256 ae2c3b34b6ed0f0bb8e322f42b53dd6a73f65c47c6e9924b190d077b868e90db

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