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
d900847d
Commit
d900847d
authored
Aug 21, 2013
by
Tom Christie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1050 from filipeximenes/master
Improving documentation about object level permissions #1049
parents
5e40e50f
1bf71234
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletions
+11
-1
docs/api-guide/generic-views.md
+4
-1
docs/api-guide/permissions.md
+7
-0
No files found.
docs/api-guide/generic-views.md
View file @
d900847d
...
...
@@ -113,7 +113,10 @@ For example:
filter = {}
for field in self.multiple_lookup_fields
:
filter[field] = self.kwargs[field]
return get_object_or_404(queryset, **filter)
obj = get_object_or_404(queryset, **filter)
self.check_object_permissions(self.request, obj)
return obj
#### `get_serializer_class(self)`
...
...
docs/api-guide/permissions.md
View file @
d900847d
...
...
@@ -28,6 +28,13 @@ If you're writing your own views and want to enforce object level permissions,
you'll need to explicitly call the
`.check_object_permissions(request, obj)`
method on the view at the point at which you've retrieved the object.
This will either raise a
`PermissionDenied`
or
`NotAuthenticated`
exception, or simply return if the view has the appropriate permissions.
For example:
def get_object(self):
obj = get_object_or_404(self.get_queryset())
self.check_object_permissions(self.request, obj)
return obj
## Setting the permission policy
The default permission policy may be set globally, using the
`DEFAULT_PERMISSION_CLASSES`
setting. For example.
...
...
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