mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 12:30:11 +03:00
multiple serializers viewset
This commit is contained in:
parent
c164d5b31d
commit
c238a2cc21
|
@ -138,3 +138,16 @@ class ModelViewSet(mixins.CreateModelMixin,
|
|||
`partial_update()`, `destroy()` and `list()` actions.
|
||||
"""
|
||||
pass
|
||||
|
||||
class MultiSerializerViewSet(ModelViewSet):
|
||||
"""
|
||||
A ModelViewSet which allows to use different serializers according to
|
||||
the currently taken action.
|
||||
"""
|
||||
serializers = {
|
||||
'default': None,
|
||||
}
|
||||
|
||||
def get_serializer_class(self):
|
||||
return self.serializers.get(self.action,
|
||||
self.serializers['default'])
|
||||
|
|
Loading…
Reference in New Issue
Block a user