diff options
| author | Philip Douglas | 2013-07-31 07:45:05 -0700 |
|---|---|---|
| committer | Philip Douglas | 2013-07-31 07:45:05 -0700 |
| commit | c058ab36b13a6979c57760d9af2eb21ec3165e7d (patch) | |
| tree | 9c352f0ebaddf18b03e45de9bf4ee3ad53377e17 /docs/api-guide/viewsets.md | |
| parent | bf8e71c455a47a53898f8239ac7dad47e5f1d53a (diff) | |
| parent | 43a5f8183c90f1056bbf33bb1402e76883aeb1fd (diff) | |
| download | django-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.md | 12 |
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. |
