diff options
| author | Tom Christie | 2013-08-21 21:31:59 +0100 | 
|---|---|---|
| committer | Tom Christie | 2013-08-21 21:31:59 +0100 | 
| commit | 16ffdedd14ed842eb019414566705d8b8392ea63 (patch) | |
| tree | cd6fe551725d60b86a57ea5812f60f054e7c1f17 /docs/api-guide/viewsets.md | |
| parent | 44ceef841543877a700c3fb4a0f84dfecbad0cbb (diff) | |
| parent | 2bcad32dcb57ae9419f6a901e081f0dcdc1a6f87 (diff) | |
| download | django-rest-framework-16ffdedd14ed842eb019414566705d8b8392ea63.tar.bz2 | |
Merge master
Diffstat (limited to 'docs/api-guide/viewsets.md')
| -rw-r--r-- | docs/api-guide/viewsets.md | 9 | 
1 files changed, 9 insertions, 0 deletions
| diff --git a/docs/api-guide/viewsets.md b/docs/api-guide/viewsets.md index 9005e7cb..c4a2d61e 100644 --- a/docs/api-guide/viewsets.md +++ b/docs/api-guide/viewsets.md @@ -19,6 +19,12 @@ Typically, rather than explicitly registering the views in a viewset in the urlc  Let's define a simple viewset that can be used to list or retrieve all the users in the system. +    from django.contrib.auth.models import User +    from django.shortcuts import get_object_or_404 +    from myapps.serializers import UserSerializer +    from rest_framework import viewsets +    from rest_framewor.responses import Response +      class UserViewSet(viewsets.ViewSet):          """          A simple ViewSet that for listing or retrieving users. @@ -41,6 +47,9 @@ If we need to, we can bind this viewset into two separate views, like so:  Typically we wouldn't do this, but would instead register the viewset with a router, and allow the urlconf to be automatically generated. +    from myapp.views import UserViewSet +    from rest_framework.routers import DefaultRouter +      router = DefaultRouter()      router.register(r'users', UserViewSet)      urlpatterns = router.urls | 
