mirror of
https://github.com/lemeow125/Django-NotesApp.git
synced 2024-11-17 14:39:25 +08:00
9 lines
No EOL
371 B
Python
9 lines
No EOL
371 B
Python
from rest_framework.permissions import BasePermission
|
|
|
|
class IsOwner(BasePermission):
|
|
"""
|
|
Custom permission to only allow the creator of an object to view and manipulate it.
|
|
"""
|
|
def has_object_permission(self, request, view, obj):
|
|
# Only allow the creator of the object to view and manipulate it.
|
|
return obj.creator == request.user |