-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filter validation too rigid for filters with suffixes #938
Comments
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 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:
django-rest-framework-json-api/rest_framework_json_api/django_filters/backends.py
Line 80 in fbb4b03
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
)The text was updated successfully, but these errors were encountered: