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 |
!= |
Greater |
> |
Greater than or is |
>= |
Less |
< |
Less than or is |
<= |
Case-insensitive contains |
* |
Case-insensitive not contains |
! |
Case-sensitive contains |
cnt |
Case-sensitive not contains |
ncnt |
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.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 278d503457a7a36040df758860ad65d74a4c33e01f4229d2bd4e3acede5ee525 |
|
MD5 | b62b65bb9bee23a026b9d1b156caf848 |
|
BLAKE2b-256 | 8d218e2bc6aa278dabf0843f83a5b994e148f7e3284d7f4e0b79dc02a4cc56f7 |