aboutsummaryrefslogtreecommitdiffstats
path: root/docs/tutorial/4-authentication-and-permissions.md
diff options
context:
space:
mode:
authorRyan Kaskel2013-05-18 14:17:50 +0100
committerRyan Kaskel2013-05-18 14:17:50 +0100
commit22874e441dd71101296a656e753bfc17907b5cca (patch)
tree6ebf7971e5bf8d40c6d60fa857cbe0c04fc91372 /docs/tutorial/4-authentication-and-permissions.md
parentb5640bb77843c50f42a649982b9b9592113c6f59 (diff)
parenta0e3c44c99a61a6dc878308bdf0890fbb10c41e4 (diff)
downloaddjango-rest-framework-22874e441dd71101296a656e753bfc17907b5cca.tar.bz2
Merge latest changes from master.
Diffstat (limited to 'docs/tutorial/4-authentication-and-permissions.md')
-rw-r--r--docs/tutorial/4-authentication-and-permissions.md16
1 files changed, 8 insertions, 8 deletions
diff --git a/docs/tutorial/4-authentication-and-permissions.md b/docs/tutorial/4-authentication-and-permissions.md
index 3ee755a2..f6c3efb0 100644
--- a/docs/tutorial/4-authentication-and-permissions.md
+++ b/docs/tutorial/4-authentication-and-permissions.md
@@ -68,12 +68,12 @@ Because `'snippets'` is a *reverse* relationship on the User model, it will not
We'll also add a couple of views. We'd like to just use read-only views for the user representations, so we'll use the `ListAPIView` and `RetrieveAPIView` generic class based views.
class UserList(generics.ListAPIView):
- model = User
+ queryset = User.objects.all()
serializer_class = UserSerializer
class UserDetail(generics.RetrieveAPIView):
- model = User
+ queryset = User.objects.all()
serializer_class = UserSerializer
Finally we need to add those views into the API, by referencing them from the URL conf.
@@ -118,17 +118,17 @@ Then, add the following property to **both** the `SnippetList` and `SnippetDetai
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
-## Adding login to the Browseable API
+## Adding login to the Browsable API
-If you open a browser and navigate to the browseable API at the moment, you'll find that you're no longer able to create new code snippets. In order to do so we'd need to be able to login as a user.
+If you open a browser and navigate to the browsable API at the moment, you'll find that you're no longer able to create new code snippets. In order to do so we'd need to be able to login as a user.
-We can add a login view for use with the browseable API, by editing our URLconf once more.
+We can add a login view for use with the browsable API, by editing our URLconf once more.
Add the following import at the top of the file:
from django.conf.urls import include
-And, at the end of the file, add a pattern to include the login and logout views for the browseable API.
+And, at the end of the file, add a pattern to include the login and logout views for the browsable API.
urlpatterns += patterns('',
url(r'^api-auth/', include('rest_framework.urls',
@@ -143,7 +143,7 @@ Once you've created a few code snippets, navigate to the '/users/' endpoint, and
## Object level permissions
-Really we'd like all code snippets to be visible to anyone, but also make sure that only the user that created a code snippet is able update or delete it.
+Really we'd like all code snippets to be visible to anyone, but also make sure that only the user that created a code snippet is able to update or delete it.
To do that we're going to need to create a custom permission.
@@ -179,7 +179,7 @@ Now, if you open a browser again, you find that the 'DELETE' and 'PUT' actions o
## Authenticating with the API
-Because we now have a set of permissions on the API, we need to authenticate our requests to it if we want to edit any snippets. We havn't set up any [authentication classes][authentication], so the defaults are currently applied, which are `SessionAuthentication` and `BasicAuthentication`.
+Because we now have a set of permissions on the API, we need to authenticate our requests to it if we want to edit any snippets. We haven't set up any [authentication classes][authentication], so the defaults are currently applied, which are `SessionAuthentication` and `BasicAuthentication`.
When we interact with the API through the web browser, we can login, and the browser session will then provide the required authentication for the requests.