A very small library for extending the functionality of DRF ModelViewSet.
Viewsets
The first of out custom viewsets is the CustomSerializerViewSet that allows you to specify different serializers for different actions of a viewset.
Quickstart
Install Rest Framework Custom ViewSets:
pip install rest_framework_custom_viewsets
then extend you ViewSet class from viewsets.CustomSerializerViewSet
Example:
from drf_custom_viewsets.viewsets.CustomSerializerViewSet from myapp.serializers import DefaltSerializer, CustomSerializer1, CustomSerializer2 class MyViewSet(CustomSerializerViewSet): serializer_class = DefaultSerializer custom_serializer_classes = { 'create': CustomSerializer1, 'update': CustomSerializer2, }
Inspired from
Tools used in rendering this package:
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/69e372be-6260-4caf-81ce-a1ff8934959a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment