ViewSet instances should have a get_serializer_context(self) method which they inherit from the generic API views. Remember that ViewSet instances are generic API views using mixins with a little extra added on top for routing purposes.
On Sun, Oct 2, 2016, 13:52 'AJ Ostergaard' via Django REST framework < [email protected]> wrote: > Is there a way to add serializer context when using viewsets? I'm > referring to the functionality discussed here > <http://www.django-rest-framework.org/api-guide/serializers/#including-extra-context> > which is difficult to implement in a viewset where only the serializer > class is defined. Could obviously be done by overriding all the methods but > that would kinda miss the point of viewsets. > > -- > 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 [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
