from rest_framework import permissions class IsOwner(permissions.BasePermission): """Grant access only if the requesting user owns the object.""" def has_object_permission(self, request, view, obj) -> bool: return obj.user == request.user