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
Unrelated assert error message when there is an error in get_queryset #4585
Comments
Hi there, this feels like a chat I had at pycon.fr. Was it with you ? That put appart, you need to provide a queryset for the view to work with routers, whether or not you override get_queryset. Will send more informations once I can use my computer. Meanwhile I'm keeping this opened as we may have a documentation issue here |
Yep, that is me. I am following the doc about this. I will give you a MWE to locate the problem more precisely. |
Thanks for raising it :) We have an inconsistence here. There's a word in the documentation about using permissions with views that don't have a I don't see a reason why routers don't use |
I'm having hard time here and disgressing, sorry about that. |
There's a good chance that if someone is overriding |
@kevin-brown good catch, thanks a lot for your feedback. That point will be solved by adding some words in the documentation. |
It seems that the problem I tried to describe is far less systematic than I thought... Raising an exception is not enough for poping an However, I think I have isolated one form of it: if (for some dumb reasons), the
It does not complain |
Okay, that's a nicely isolated bit of behavior that'd be worth addressing. Let's constrain this issue to just that particular aspect, at least for now. |
In a view, I have define a
get_queryset
method in aAPIView
derived class. For some (not important) reasons, I have made a mistake in my code, but the error message I get is unrelated to the actual mistake: it is anAssertError
, complaining there is no.queryset
attribute orget_queryset
method in the view. And the traceback does only imply files of the framework, not files I haver written and, obviously, neither the file I have made the mistake in.Steps to reproduce
Create a class in
views.py
, deriving fromAPIView
. Define aget_queryset
method with a mistake in it,say anthe method do not return anything. Run it.IndexError
.Txpected behavior
Get an error message involving anIndexError
.Get an error message about the empty return of
get_queryset
.Actual behavior
Get an error message related to an
AssertError
.The text was updated successfully, but these errors were encountered: