You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/api/v1/orders/order/?user=1 - works great.
but I need to use customer in query instead of real model name user: /api/v1/orders/order/?customer=1
I tried this:
class OrderFilter(filters.FilterSet):
File "/home/guest007/.pyenv/versions/3.6.5/envs/pex/src/djangorestframework-filters/rest_framework_filters/filterset.py", line 21, in __new__
cls.expand_auto_filters(new_class)
File "/home/guest007/.pyenv/versions/3.6.5/envs/pex/src/djangorestframework-filters/rest_framework_filters/filterset.py", line 42, in expand_auto_filters
for gen_name, gen_f in new_class.get_filters().items():
File "/home/guest007/.pyenv/versions/pex/lib/python3.6/site-packages/django_filters/filterset.py", line 280, in get_filters
fields = cls.get_fields()
File "/home/guest007/.pyenv/versions/3.6.5/envs/pex/src/djangorestframework-filters/rest_framework_filters/filterset.py", line 88, in get_fields
fields[name] = utils.lookups_for_field(field)
File "/home/guest007/.pyenv/versions/3.6.5/envs/pex/src/djangorestframework-filters/rest_framework_filters/utils.py", line 31, in lookups_for_field
for expr, lookup in model_field.get_lookups().items():
AttributeError: 'NoneType' object has no attribute 'get_lookups'
where I was mistaken?
The text was updated successfully, but these errors were encountered:
Yep - django-filter 1.1.0 should raise deprecation warnings about name being renamed to field_name. In 2.x, the warning and backwards compatibility was removed (see: carltongibson/django-filter#795).
Also, it's worth noting that the filter's attribute name is used as a default value when no field_name is explicitly provided. The first example works, because the filter's attribute name and the underlying model field name are the same. The latter didn't work, because customer is not a field on your model.
installs django-rest-framework-filters (fresh from github)
python 3.6.5, django 2
This code is work.
/api/v1/orders/order/?user=1
- works great.but I need to use
customer
in query instead of real model nameuser
:/api/v1/orders/order/?customer=1
I tried this:
And got:
where I was mistaken?
The text was updated successfully, but these errors were encountered: