Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7k
Closed
Labels
Milestone
Description
When turning on PAGINATE_BY in settingsAdding Pagination
REST_FRAMEWORK= {'PAGINATE_BY':10}
The custom permissionsObject Level Permissions
fromrest_frameworkimportpermissionsclassIsOwnerOrReadOnly(permissions.BasePermission):""" Custom permission to only allow owners of an object to edit it. """defhas_object_permission(self,request,view,obj):# Read permissions are allowed to any request,# so we'll always allow GET, HEAD, or OPTIONS requests.ifrequest.methodinpermissions.SAFE_METHODS:returnTrueprint(obj)# Write permissions are only allowed to the owner of the snippet.returnobj.owner==request.user
break when trying to view the list of Snippets with the following error:
AttributeError at /snippets/'Page' object has no attribute 'owner'Request Method: GETRequest URL: http://127.0.0.1:8000/snippets/Django Version: 1.7.1Exception Type: AttributeErrorException Value: 'Page' object has no attribute 'owner'Exception Location: /Development/Python/django/snippets_tutorial/snippets/permissions.py in has_object_permission, line 14When disabling the PAGINATE_BY setting you are able to view the Snippets list without any error.