Discussion:
Different Serializers in ModelViewSet
Tobias Reese
2018-09-24 16:05:21 UTC
Permalink
Is there a way to define different Serializers within a ModelViewSet Mixin
like CreateModelMixin?
I found several threads having different Serializers for different Methods.
But i need to accept different
schemas on the POST and GET Methods.

I think it is no Problem to override the create method and select the
correct serializer within it, but doing this will
break the swagger generation. Is there a way to annotate the create Method
to have correct swagger documentation
with @swagger_auto_schema (show 2 possible Schemas for Method)?
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jason
2018-09-24 20:56:47 UTC
Permalink
override and re-implement get_serializer_class
<https://github.com/encode/django-rest-framework/blob/master/rest_framework/generics.py#L114-L130>
Post by Tobias Reese
Is there a way to define different Serializers within a ModelViewSet Mixin
like CreateModelMixin?
I found several threads having different Serializers for different
Methods. But i need to accept different
schemas on the POST and GET Methods.
I think it is no Problem to override the create method and select the
correct serializer within it, but doing this will
break the swagger generation. Is there a way to annotate the create Method
to have correct swagger documentation
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...