-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Allow DjangoObjectPermissions to use views that define get_queryset #2864
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
Looks good to me too. |
Shouldn't this instead behave like try:
queryset = view.get_queryset()
except AttributeError:
queryset = getattr(view, 'queryset', None)
except AssertionError:
# view.get_queryset() didn't find .queryset
queryset = None I think there's also some docs that need to be updated. |
There is no use case for |
9df21d7
to
76bc42c
Compare
@@ -172,7 +172,7 @@ def get_required_object_permissions(self, method, model_cls): | |||
return [perm % kwargs for perm in self.perms_map[method]] | |||
|
|||
def has_object_permission(self, request, view, obj): | |||
model_cls = view.queryset.model | |||
model_cls = view.get_queryset().model |
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.
Should we also fallback to view.queryset.model
? That'd be consistent with the documentation above, and would be less likely to introduce any breakage to existing APIs.
Also then more consistent with #2863.
One inline comment. Once that's addressed I'm happy with this. |
the default implementation of This is why I think we do not need to fallback on Therefore, for sake of consistency, I will do it the same way, by asserting the queryset exists, like it is done for |
I will re-open later . I need to work on this branch a bit more. |
Same as #2863 but for
DjangoObjectPermissions
.