Build custom filtering feature to support complex queries for Django
The API filtering has to allow using parenthesis for defining operations precedence and use any combination of the available fields. The supported operations include or, and, eq (equals), ne (not equals), gt (greater than), lt (lower than). Example -> "(date eq 2016-05-01) AND ((distance gt 20) OR (distance lt 10))" Example 2 -> "distance lt 10" Interface should look like this: def parse_search_phrase(allowed_fields, phrase): ... return Q(...) so I can use it like: search_filter = parse_search_phrase(allowed_fields, search_phrase) queryset = MyModel.objects.filter(search_filter)