Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
d8a95b4b
Commit
d8a95b4b
authored
Dec 23, 2013
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Back out permissions example change in favor of easier to follow example
parent
c3857236
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
docs/tutorial/4-authentication-and-permissions.md
+5
-2
No files found.
docs/tutorial/4-authentication-and-permissions.md
View file @
d8a95b4b
...
@@ -167,8 +167,11 @@ In the snippets app, create a new file, `permissions.py`
...
@@ -167,8 +167,11 @@ In the snippets app, create a new file, `permissions.py`
def has_object_permission(self, request, view, obj):
def has_object_permission(self, request, view, obj):
# Read permissions are allowed to any request,
# Read permissions are allowed to any request,
# so we'll always allow GET, HEAD or OPTIONS requests.
# so we'll always allow GET, HEAD or OPTIONS requests.
# Write permissions are only allowed to the owner of the snippet
if request.method in permissions.SAFE_METHODS:
return request.method in permissions.SAFE_METHODS or obj.owner == request.user
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:
Now we can add that custom permission to our snippet instance endpoint, by editing the
`permission_classes`
property on the
`SnippetDetail`
class:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment