Closed nrabe closed 3 years ago
I have a different error on the same call:
class RetrieveSqlQueryKeyBit(SqlQueryKeyBitBase):
def get_data(self, params, view_instance, view_method, request, args, kwargs):
lookup_value = view_instance.kwargs[view_instance.lookup_field]
try:
queryset = view_instance.filter_queryset(view_instance.get_queryset()).filter(
**{view_instance.lookup_field: lookup_value}
)
except ValueError:
return None
else:
return self._get_queryset_query_string(queryset)
Is now giving:
AttributeError at /v1/catalogue/category/32
type object 'Category' has no attribute 'filter'
Request Method: GET
Request URL: http://127.0.0.1:8000/v1/catalogue/category/32
Django Version: 1.8.4
Exception Type: AttributeError
Exception Value:
type object 'Category' has no attribute 'filter'
Exception Location: /Users/Documents/workspace/app/django-env/lib/python2.7/site-packages/rest_framework_extensions/key_constructor/bits.py in get_data, line 208
Python Executable: /Users/Documents/workspace/app/django-env/bin/python
File "/home/vagrant/.virtualenvs/todoapp1/local/lib/python2.7/site-packages/rest_framework_extensions/key_constructor/bits.py", line 201, in get_data lookup_value = view_instance.kwargs[view_instance.lookup_field] KeyError: 'slug'
I believe view_instance.lookup_field should be replaced with: view_instance.lookup_url_kwarg.