aboutsummaryrefslogtreecommitdiffstats
path: root/docs/tutorial/4-authentication-and-permissions.md
diff options
context:
space:
mode:
authorsshquack2014-08-15 20:45:28 -0600
committersshquack2014-08-15 20:45:28 -0600
commit867e441ec07fc182569c3dbe6f86fe42aa6b0cbf (patch)
treeabed866613809f8efe96d03dac3e8d1dffb950d8 /docs/tutorial/4-authentication-and-permissions.md
parent14867705e90b2b5f7e84dc7385d4ffba0c82b3e1 (diff)
downloaddjango-rest-framework-867e441ec07fc182569c3dbe6f86fe42aa6b0cbf.tar.bz2
Strip trailing spaces in tutorial
Diffstat (limited to 'docs/tutorial/4-authentication-and-permissions.md')
-rw-r--r--docs/tutorial/4-authentication-and-permissions.md12
1 files changed, 6 insertions, 6 deletions
diff --git a/docs/tutorial/4-authentication-and-permissions.md b/docs/tutorial/4-authentication-and-permissions.md
index bdbe00ab..74ad9a55 100644
--- a/docs/tutorial/4-authentication-and-permissions.md
+++ b/docs/tutorial/4-authentication-and-permissions.md
@@ -73,12 +73,12 @@ We'll also add a couple of views to `views.py`. We'd like to just use read-only
class UserList(generics.ListAPIView):
queryset = User.objects.all()
serializer_class = UserSerializer
-
-
+
+
class UserDetail(generics.RetrieveAPIView):
queryset = User.objects.all()
serializer_class = UserSerializer
-
+
Make sure to also import the `UserSerializer` class
from snippets.serializers import UserSerializer
@@ -157,8 +157,8 @@ To do that we're going to need to create a custom permission.
In the snippets app, create a new file, `permissions.py`
from rest_framework import permissions
-
-
+
+
class IsOwnerOrReadOnly(permissions.BasePermission):
"""
Custom permission to only allow owners of an object to edit it.
@@ -201,7 +201,7 @@ If we try to create a snippet without authenticating, we'll get an error:
We can make a successful request by including the username and password of one of the users we created earlier.
curl -X POST http://127.0.0.1:8000/snippets/ -d "code=print 789" -u tom:password
-
+
{"id": 5, "owner": "tom", "title": "foo", "code": "print 789", "linenos": false, "language": "python", "style": "friendly"}
## Summary