From 3ffe8dcfacf6250f0bf1dc4c35d646fa804e9e95 Mon Sep 17 00:00:00 2001 From: emilio Date: Wed, 29 Oct 2014 19:51:06 +0100 Subject: [PATCH] doc for MultiSerializerViewSet --- docs/api-guide/viewsets.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/api-guide/viewsets.md b/docs/api-guide/viewsets.md index 9030e3ee0..9e358a87a 100644 --- a/docs/api-guide/viewsets.md +++ b/docs/api-guide/viewsets.md @@ -220,6 +220,20 @@ As with `ModelViewSet`, you'll normally need to provide at least the `queryset` Again, as with `ModelViewSet`, you can use any of the standard attributes and method overrides available to `GenericAPIView`. +## MultiSerializerViewSet +The `MultiSerializerViewSet` is an extension to the `ModelViewSet` which adds the possibility of using more than one serializer depending on the action currently taken. When the action is not found in the `serializers` dictionary, the provided default serializer will be used instead. + +#### Example + class UserGroupsViewSet(MultiSerializerViewSet): + model = models.Groups + + serializers = { + 'list': myserializers.GroupListSerializer, + 'detail': myserializers.GroupDetailSerializer, + 'default': serializers.HyperlinkedModelSerializer, + } + + # Custom ViewSet base classes You may need to provide custom `ViewSet` classes that do not have the full set of `ModelViewSet` actions, or that customize the behavior in some other way.