diff options
| author | amatellanes | 2013-12-23 08:56:34 +0100 | 
|---|---|---|
| committer | amatellanes | 2013-12-23 08:56:34 +0100 | 
| commit | 74f1cf635536ea99937954a11fa11531a832ebc2 (patch) | |
| tree | 2a728f85b59d30e38e7b4f416738e9b30e2ea2af /docs/tutorial/4-authentication-and-permissions.md | |
| parent | d6806340e54408858da4b2dc991be99edd65df76 (diff) | |
| download | django-rest-framework-74f1cf635536ea99937954a11fa11531a832ebc2.tar.bz2 | |
Revert "Simplified some examples in tutorial"
This reverts commit d6806340e54408858da4b2dc991be99edd65df76.
Diffstat (limited to 'docs/tutorial/4-authentication-and-permissions.md')
| -rw-r--r-- | docs/tutorial/4-authentication-and-permissions.md | 7 | 
1 files changed, 5 insertions, 2 deletions
| diff --git a/docs/tutorial/4-authentication-and-permissions.md b/docs/tutorial/4-authentication-and-permissions.md index 986f13ff..b472322a 100644 --- a/docs/tutorial/4-authentication-and-permissions.md +++ b/docs/tutorial/4-authentication-and-permissions.md @@ -163,12 +163,15 @@ 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 request.method in permissions.SAFE_METHODS or obj.owner == request.user +            return 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: | 
