If you have a problem with permissions_classes in your custom actions in the ViewSet, try using this decorator for your action. Probably the new Django Rest Framework is not considering permissions. The solution to this situation is to check it yourself at the beginning of each user action or use the following decorator:
def check_permissions(fun): def ref(self, request, pk=None): obj = get_object_or_404(self.get_queryset(), pk=pk) self.check_object_permissions(self.request, obj) return fun(self, request, pk) return ref
Marcin Ziฤ
bek
source share