Commit d8a95b4b by Tom Christie

Back out permissions example change in favor of easier to follow example

parent c3857236
......@@ -167,8 +167,11 @@ In the snippets app, create a new file, `permissions.py`
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.
# Write permissions are only allowed to the owner of the snippet
return request.method in permissions.SAFE_METHODS or obj.owner == request.user
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
Now we can add that custom permission to our snippet instance endpoint, by editing the `permission_classes` property on the `SnippetDetail` class:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment