Add compatibility for DRF 3.12

This commit is contained in:
Dhaval Mehta 2020-06-23 13:20:22 +05:30
parent de08967210
commit ca355baf7a

View File

@ -78,10 +78,10 @@ class LoginView(GenericAPIView):
'refresh_token': self.refresh_token 'refresh_token': self.refresh_token
} }
serializer = serializer_class(instance=data, serializer = serializer_class(instance=data,
context={'request': self.request}) context=self.get_serializer_context())
else: else:
serializer = serializer_class(instance=self.token, serializer = serializer_class(instance=self.token,
context={'request': self.request}) context=self.get_serializer_context())
response = Response(serializer.data, status=status.HTTP_200_OK) response = Response(serializer.data, status=status.HTTP_200_OK)
if getattr(settings, 'REST_USE_JWT', False): if getattr(settings, 'REST_USE_JWT', False):
@ -106,7 +106,7 @@ class LoginView(GenericAPIView):
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
self.request = request self.request = request
self.serializer = self.get_serializer(data=self.request.data, self.serializer = self.get_serializer(data=self.request.data,
context={'request': request}) context=self.get_serializer_context())
self.serializer.is_valid(raise_exception=True) self.serializer.is_valid(raise_exception=True)
self.login() self.login()