aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide/viewsets.md
diff options
context:
space:
mode:
authorPhilip Douglas2013-07-31 07:45:05 -0700
committerPhilip Douglas2013-07-31 07:45:05 -0700
commitc058ab36b13a6979c57760d9af2eb21ec3165e7d (patch)
tree9c352f0ebaddf18b03e45de9bf4ee3ad53377e17 /docs/api-guide/viewsets.md
parentbf8e71c455a47a53898f8239ac7dad47e5f1d53a (diff)
parent43a5f8183c90f1056bbf33bb1402e76883aeb1fd (diff)
downloaddjango-rest-framework-c058ab36b13a6979c57760d9af2eb21ec3165e7d.tar.bz2
Merge pull request #2 from tomchristie/master
Update to latest
Diffstat (limited to 'docs/api-guide/viewsets.md')
-rw-r--r--docs/api-guide/viewsets.md12
1 files changed, 7 insertions, 5 deletions
diff --git a/docs/api-guide/viewsets.md b/docs/api-guide/viewsets.md
index 25d11bfb..0c68afb0 100644
--- a/docs/api-guide/viewsets.md
+++ b/docs/api-guide/viewsets.md
@@ -98,8 +98,10 @@ For example:
from django.contrib.auth.models import User
from rest_framework import viewsets
+ from rest_framework import status
from rest_framework.decorators import action
- from myapp.serializers import UserSerializer
+ from rest_framework.response import Response
+ from myapp.serializers import UserSerializer, PasswordSerializer
class UserViewSet(viewsets.ModelViewSet):
"""
@@ -176,7 +178,7 @@ Note that you can use any of the standard attributes or method overrides provide
permission_classes = [IsAccountAdminOrReadOnly]
def get_queryset(self):
- return request.user.accounts.all()
+ return self.request.user.accounts.all()
Also note that although this class provides the complete set of create/list/retrieve/update/destroy actions by default, you can restrict the available operations by using the standard permission classes.
@@ -205,9 +207,9 @@ You may need to provide custom `ViewSet` classes that do not have the full set o
To create a base viewset class that provides `create`, `list` and `retrieve` operations, inherit from `GenericViewSet`, and mixin the required actions:
- class CreateListRetrieveViewSet(mixins.CreateMixin,
- mixins.ListMixin,
- mixins.RetrieveMixin,
+ class CreateListRetrieveViewSet(mixins.CreateModelMixin,
+ mixins.ListModelMixin,
+ mixins.RetrieveModelMixin,
viewsets.GenericViewSet):
"""
A viewset that provides `retrieve`, `update`, and `list` actions.