@@ -55,6 +55,7 @@
Authentication
Permissions
Throttling
+
Pagination
Content negotiation
Format suffixes
Returning URLs
@@ -134,6 +135,7 @@
You can also set the authentication policy on a per-view basis, using the APIView
class based views.
class ExampleView(APIView):
authentication_classes = (SessionAuthentication, UserBasicAuthentication)
+ permission_classes = (IsAuthenticated,)
def get(self, request, format=None):
content = {
@@ -143,10 +145,9 @@
return Response(content)
Or, if you're using the @api_view
decorator with function based views.
-
@api_view(
- allowed=('GET',),
- authentication_classes=(SessionAuthentication, UserBasicAuthentication)
-)
+@api_view('GET'),
+@authentication_classes(SessionAuthentication, UserBasicAuthentication)
+@permissions_classes(IsAuthenticated)
def example_view(request, format=None):
content = {
'user': unicode(request.user), # `django.contrib.auth.User` instance.
@@ -218,4 +219,4 @@ print token.key
event.stopPropagation();
});
-
\ No newline at end of file
+