def get_serializer_context(self):
    default return is
        'request': self.request,
        'format': self.format_kwarg,
        'view': self
    context = super(YourViewSet, self).get_serializer_context()
    # You can add what you want
    context['device_id'] = self.request.META.get('HTTP_DEVICEID', '')
    return context

I got some typo. you have to return context in get_serializer_context.

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 
For more options, visit

Reply via email to