Created
April 17, 2015 08:24
-
-
Save Kobold/c5ead2b72b2be03eb0ca to your computer and use it in GitHub Desktop.
Revisions
-
Kobold created this gist
Apr 17, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ from rest_framework import permissions class IsOwner(permissions.BasePermission): """ Custom permission to only allow owners of an object to edit it. """ def has_permission(self, request, view): return request.user and request.user.is_authenticated() def has_object_permission(self, request, view, obj): return obj.user == request.user