Hi everybody,

I try use a two serializers in one view inherits from *GenericViewSet* with 
the method *get_serializer_class*

Here a little piece of my code:

class RandomViewSet(ListModelMixin, GenericViewSet):
    permission_classes = (IsAuthenticated, )
    filter_backends = [filters.SearchFilter, filters.OrderingFilter, ]
    search_fields = ['some_field', 'some_field', 'some_field', ]
    ordering_fields = ['pk', ]
    ordering = ['pk', ]
    lookup_field = 'pk'
    serializer_class = OneSerializer
    serializers = {
        'list': OneSerializer,
        'create': TwoSerializer,
    }

    def get_serializer_class(self, *args, **kwargs):
        print('THIS METHOD DON\'T WORK')
        return self.serializers.get(self.action)


    def create(self, request, *args, **kwargs):

        print('Data is not validated :(')




Any help for this?

Greetings,


-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-rest-framework/438adf7c-e2d5-480c-8716-9bd83116c902%40googlegroups.com.

Reply via email to