aboutsummaryrefslogtreecommitdiffstats
path: root/docs/tutorial/4-authentication-and-permissions.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/tutorial/4-authentication-and-permissions.md')
-rw-r--r--docs/tutorial/4-authentication-and-permissions.md7
1 files changed, 2 insertions, 5 deletions
diff --git a/docs/tutorial/4-authentication-and-permissions.md b/docs/tutorial/4-authentication-and-permissions.md
index b472322a..986f13ff 100644
--- a/docs/tutorial/4-authentication-and-permissions.md
+++ b/docs/tutorial/4-authentication-and-permissions.md
@@ -163,15 +163,12 @@ In the snippets app, create a new file, `permissions.py`
"""
Custom permission to only allow owners of an object to edit it.
"""
-
+
def has_object_permission(self, request, view, obj):
# Read permissions are allowed to any request,
# so we'll always allow GET, HEAD or OPTIONS requests.
- if request.method in permissions.SAFE_METHODS:
- return True
-
# Write permissions are only allowed to the owner of the snippet
- return obj.owner == request.user
+ return request.method in permissions.SAFE_METHODS or obj.owner == request.user
Now we can add that custom permission to our snippet instance endpoint, by editing the `permission_classes` property on the `SnippetDetail` class: