-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Prevent empty queryset
s to raise AssertionError.
#2862
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
Conversation
70d566a
to
477a803
Compare
This >>> bool(queryset) is False
True
>>> assert queryset, 'no queryset define on the view'
AssertionError 'no queryset define on the view' Which is a lie. |
OK — this seems good to me. @tomchristie I'm feeling rusty: can you just cast your eye over it — but looks good yes? |
@xordoquy — Since you're about — can you look at this too? (Ta!) |
I will rebase it |
477a803
to
6f66798
Compare
done. |
@@ -120,7 +120,7 @@ def has_permission(self, request, view): | |||
if queryset is None and getattr(view, '_ignore_model_permissions', False): | |||
return True | |||
|
|||
assert queryset, ( | |||
assert queryset is not None, ( | |||
'Cannot apply DjangoModelPermissions on a view that ' | |||
'does not have `.queryset` property.' | |||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change this lines to:
'Cannot apply DjangoModelPermissions on a view that '
'does not have `.queryset` property nor redefines `.get_queryset()`'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright
let me know if you prefer I squash the commits. |
It's ok for me. I'm just waiting the tests to be finished and I'll merge it. |
Excellent, thank you. |
👍 |
Prevent empty `queryset`s to raise AssertionError.
Thanks to you in the first place :) |
No description provided.