Open SafaAlfulaij opened 3 years ago
I agree this is a bug and this should actually work. There are also other suffixes used like min and max which should work too. Any there could be custom suffixes as well. So I wonder instead of validating those filters on our own, whether there is a easy way to let the filter class validate the filters.
Yes, it looks like it's a duplicate, sorry for opining another issue.
Are there any plans to fix it? This issue has been open for more than a year.
@eloi-martinez-qida No worries. Welcome to DJA! This is an OSS project with only volunteer contributors. So people work on the issues which are most relevant to them.
Therefore, if you are affected by this issue, I encourage you to work on a PR. Happy to assist if needed.
@sliverc What would be the best way to tackle the problem?
The best way would be to check whether the django filter class has a way to validate the filter names.
Here: https://github.com/django-json-api/django-rest-framework-json-api/blob/fbb4b033a483b7edb62de3377c83a046a55f69b2/rest_framework_json_api/django_filters/backends.py#L80
RangeFilter
is used to specify a value of the two ends without specifying the other. It works by looking for "min/after" and "max/before" in the query param.This should work:
Using
DateFromToRangeFilter
, defined this way:and passing the filter:
filters[last_updated_after]=2016-01-01
will execute:
.filter(last_updated__gte="2016-01-01")
Currently it fails as
last_updated_after
!=last_updated
(as in the quoted code:base_filters
containslast_updated
but notlast_updated_after
orlast_updated_before
)