-
Notifications
You must be signed in to change notification settings - Fork 58
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
Decorators don't work with class methods #21
Comments
You're right, the decorators don't work with classmethods. However, you can still use classmethods for global permissions, you just can't also use the decorators on top of that. That being said, it would be nice to be able to do both. I will look into a solution. |
Hi all, not familiar with dry-rest-permissions yet but just browsing and saw this issue. HTH. |
Sorry if I don't understand deeply the problem, it is not possible to fix this problem? Looking at the decorators I see that the There any problem if it gets generalized to ? from rest_framework.request import Request
...
request = args[0] if isinstance(args[0], Request) else args[1] Probably we can even use duck-typing to identify the |
The documentation states that global permissions can be implemented as either
@staticmethod
or@classmethod
on the model. The decorators (e.g.@unauthenticated_users
) assume the first argument of the global permissions methods is aRequest
. This is true if the methods are static methods. However, when implemented as class methods, the first argument is the class itself.Either the decorators should be updated, or the documentation should be modified to note this issue and/or remove the mention of
@classmethod
.The text was updated successfully, but these errors were encountered: