def get_serializer_context(self):
    """
    Extra context provided to the serializer class.
    """
return {'request': self.request, 'format': self.format_kwarg, 'view': self}
Accessing Request Object in Viewset and Serializers in Django Rest Framework?