view.get_queryset() is called if an array (instead of a dict) is passed to rest_framework.response.Response and rest_framework.exceptions are not being handled correctly. #8842
Unanswered
davemagro
asked this question in
Potential Issue
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I find it pretty common to raise a
rest_framework.exceptions.NotFound
exception insideget_queryset()
especially when using drf-nested-router.When you pass a list to the
Response()
object (likereturn Response([])
) in a viewset method defined by therest_framework.decorators.action()
without callingself.get_queryset()
inside the said viewset method, then an HTTP status 500 will be returned to the user.drf-nested-router is setup in such a way that the following paths are created:
accessing
/accounts/{account_pk}/assets/
will cause the HTTP 500 error that I mentioned.This is the code which is invoking the
view.get_queryset()
method when a list is passed to theResponse
object.django-rest-framework/rest_framework/renderers.py
Line 626 in 0618fa8
Beta Was this translation helpful? Give feedback.
All reactions