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.1.tar.gz
(11.9 kB
view hashes)
Built Distribution
Close
Hashes for drf_complex_filter-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfe056821c7b77e3dace96f5ec102a7e2cdda96e44047c4101ea226e41318661 |
|
MD5 | 02933591828b13b752cda46fa69a5248 |
|
BLAKE2b-256 | 9cea233c557c3066736406679956b8b24bd4b553d692e46fb5c24531b9ae5b05 |