Reputation: 951
I have a view:
class DealsView(APIView):
permission_classes = (IsAuthenticated, IsOwnerOrCuratorOrDirectorOrNotAllowed, )
def get(self, request, user_pk):
...
But in order to check the permissions correctly I need to pass user_pk url argument to permission:
class IsOwnerOrCuratorOrDirectorOrNotAllowed(permissions.BasePermission):
def has_permission(self, request, view):
...
By default it doesn't have any arguments except self, request, and view. How can I go through it?
Upvotes: 4
Views: 2968
Reputation: 1116
Try this:
class IsOwnerOrCuratorOrDirectorOrNotAllowed(permissions.BasePermission):
def has_permission(self, request, view):
user_pk = view.kwargs.get('user_pk', None)
...
Upvotes: 19