From 9041e470583567866bbd793707dd8cfb71185cd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B8=D0=BA=D0=B8=D0=BD=20=D0=98=D0=B3=D0=BE?= =?UTF-8?q?=D1=80=D1=8C=20=D0=9C=D0=B8=D1=85=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2?= =?UTF-8?q?=D0=B8=D1=87?= Date: Fri, 17 Jul 2015 13:04:49 +0300 Subject: [PATCH] Add permissions --- docs/tutorial/2-requests-and-responses.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/tutorial/2-requests-and-responses.md b/docs/tutorial/2-requests-and-responses.md index 51cea4f1b..c9a61f2f2 100644 --- a/docs/tutorial/2-requests-and-responses.md +++ b/docs/tutorial/2-requests-and-responses.md @@ -42,9 +42,11 @@ We don't need our `JSONResponse` class in `views.py` anymore, so go ahead and de from rest_framework.response import Response from snippets.models import Snippet from snippets.serializers import SnippetSerializer + from rest_framework.permissions import IsAuthenticatedOrReadOnly @api_view(['GET', 'POST']) + @permission_classes((IsAuthenticatedOrReadOnly,)) def snippet_list(request): """ List all snippets, or create a new snippet. @@ -66,6 +68,7 @@ Our instance view is an improvement over the previous example. It's a little mo Here is the view for an individual snippet, in the `views.py` module. @api_view(['GET', 'PUT', 'DELETE']) + @permission_classes((IsAuthenticatedOrReadOnly,)) def snippet_detail(request, pk): """ Retrieve, update or delete a snippet instance.