[Django]-How to use has_object_permission with APIView in Django Rest Framework?

0👍

If you need the operator Or ,you can import rest_condition:

pip install rest_condition

And in your view import Or from rest_condition and do the following on the permission_classes:

permission_classes = [Or(CustomObjectPermissions,IsOwner)]

But I don’t think the error is caused because Or is missing,you can tackle this problem from another prespective, you can have the get request returning only that user’s information so he can modify:

def get_queryset(self):
   serializer = self.get_serializer()
   owner = serializer.context['request'].user
   return User.objects.filter(id=owner.id)

Leave a comment