aboutsummaryrefslogtreecommitdiffstats
path: root/docs/tutorial/4-authentication-and-permissions.md
diff options
context:
space:
mode:
authorTom Christie2013-12-23 01:10:13 -0800
committerTom Christie2013-12-23 01:10:13 -0800
commitc385723648710d0cb5757a8829826dfe77b31036 (patch)
tree6922257bd3c636dc490239d999f79e3901f3e64e /docs/tutorial/4-authentication-and-permissions.md
parent9b7341e4840635d9c3bd419678164cdc3cbb7d20 (diff)
parent2846ddb5d2ba84b3905d4dc0593afe3a0d4b2749 (diff)
downloaddjango-rest-framework-c385723648710d0cb5757a8829826dfe77b31036.tar.bz2
Merge pull request #1315 from amatellanes/master
Simplified some examples in tutorial
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: