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
Built Distribution
Close
Hashes for drf_complex_filter-0.2.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1e2455cd040e173a16397cf2e93040fea797b751dc1ac4f9e6a6dfad516425a |
|
MD5 | ea43ea627984474ed36fa8930ba2fa74 |
|
BLAKE2b-256 | f09a1707e6bc72c11c23fcbd5538faf3e8ab4cbeaac9db4e8aee4312704b507b |