Skip to content

Commit

Permalink
Docs tweaking around check_object_permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchristie committed Aug 21, 2013
1 parent d900847 commit cf6ae39
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/api-guide/generic-views.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ For example:
self.check_object_permissions(self.request, obj)
return obj

Note that if your API doesn't include any object level permissions, you may optionally exclude the ``self.check_object_permissions, and simply return the object from the `get_object_or_404` lookup.

#### `get_serializer_class(self)`

Returns the class that should be used for the serializer. Defaults to returning the `serializer_class` attribute, or dynamically generating a serializer class if the `model` shortcut is being used.
Expand Down
3 changes: 2 additions & 1 deletion docs/api-guide/permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Object level permissions are run by REST framework's generic views when `.get_ob
As with view level permissions, an `exceptions.PermissionDenied` exception will be raised if the user is not allowed to act on the given object.

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.
or if you override the `get_object` method on a generic view, then 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:
Expand Down

0 comments on commit cf6ae39

Please sign in to comment.