DRF filter for complex queries.
Project description
DRF filter for complex queries
Installing
For installing use pip
$ pip install drf-complex-filter
Usage
Add ComplexQueryFilter to filter_backends:
from drf_complex_filter.filters import ComplexQueryFilter class UserViewSet(ModelViewSet): queryset = User.objects.all() serializer_class = UserSerializer filter_backends = [ComplexQueryFilter]
And get some records
GET /users?filters={"type":"operator","data":{"attribute":"first_name","operator":"=","value":"John"}}
Filter operator
Operator may be one of three types
{ "type": "operator", "data": { "attribute": "field_name", "operator": "one_of_lookup_operators", "value": "value_for_compare", } }
{ "type": "and", "data": [] }
{ "type": "or", "data": [] }
Lookup operators
Operator label |
Query operator |
---|---|
Is |
= |
Is not |
!= |
Case-insensitive contains |
* |
Case-insensitive not contains |
! |
Greater |
> |
Greater than or is |
>= |
Less |
< |
Less than or is |
<= |
Value in list |
in |
Value not in list |
not_in |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
drf-complex-filter-1.0.0.tar.gz
(11.9 kB
view hashes)
Built Distribution
Close
Hashes for drf_complex_filter-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86ef95ebfb9cf3f52b00d9972d0b5cd8c1c0272b5dbd8b6731576c817f5f96c0 |
|
MD5 | 360841819db25e18297cd9c8a56725bb |
|
BLAKE2b-256 | cc061213546ab7edb89c328a76b93eccb12b3ff954da7910065d139ed32abe41 |