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.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f48dd440251e4fe1518352032f8837373b9b550baa422b1b6fdd1d8bc97de52 |
|
MD5 | 1db42cdae2e9c3c0e5230d857f6419af |
|
BLAKE2b-256 | d3904a933c54eed945e677e95fc3c6e64cd77a26c14c043cf367d8c165920e6f |