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

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 2.7 and 3.4

  • Django 1.2 through to 1.8 alpha 1

  • Django REST Framework 2.4 and 3.0 (optional)

Documentation

See http://filternaut.readthedocs.org/en/latest/ 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.2.tar.gz (6.8 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.2-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for django-filternaut-0.0.2.tar.gz
Algorithm Hash digest
SHA256 cc69fdd532d610f2297e8d28a99f90df831c5a6754ab1e25c2235a093b66bcd6
MD5 7adfa50cd544574830a48f7829dfefa7
BLAKE2b-256 90a8238634a37311318c58101fd0fc81cf737dd51a6164121aa9d7d6ed781713

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_filternaut-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a83a2438888e66caf0fa6e3b293242a2cda69dc7834b9c1c66ba368eb00d237a
MD5 c9b9e32c815a04afe5b09ae26c98417c
BLAKE2b-256 efc9fb8c7750e89e6c4ece06ac3025aa6f1589d1745d146de67df23f9b2e7349

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