passing on the context/request to serializer

This commit is contained in:
Girish 2016-04-14 12:54:50 +01:00
parent 49ccfe92a9
commit 22667230bb

View File

@ -63,9 +63,9 @@ class LoginView(GenericAPIView):
'user': self.user, 'user': self.user,
'token': self.token 'token': self.token
} }
serializer = serializer_class(instance=data) serializer = serializer_class(instance=data, context={'request': self.request})
else: else:
serializer = serializer_class(instance=self.token) serializer = serializer_class(instance=self.token, context={'request': self.request})
return Response(serializer.data, status=status.HTTP_200_OK) return Response(serializer.data, status=status.HTTP_200_OK)