From ca355baf7ad5206521ae7c738c5972438fcc58ad Mon Sep 17 00:00:00 2001 From: Dhaval Mehta <20968146+dhaval-mehta@users.noreply.github.com> Date: Tue, 23 Jun 2020 13:20:22 +0530 Subject: [PATCH 1/2] Add compatibility for DRF 3.12 --- dj_rest_auth/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dj_rest_auth/views.py b/dj_rest_auth/views.py index 21e064c..a5d06d7 100644 --- a/dj_rest_auth/views.py +++ b/dj_rest_auth/views.py @@ -78,10 +78,10 @@ class LoginView(GenericAPIView): 'refresh_token': self.refresh_token } serializer = serializer_class(instance=data, - context={'request': self.request}) + context=self.get_serializer_context()) else: serializer = serializer_class(instance=self.token, - context={'request': self.request}) + context=self.get_serializer_context()) response = Response(serializer.data, status=status.HTTP_200_OK) if getattr(settings, 'REST_USE_JWT', False): @@ -106,7 +106,7 @@ class LoginView(GenericAPIView): def post(self, request, *args, **kwargs): self.request = request 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.login() From 1b2073a1872c2e22426746dc2c27a734e83462b7 Mon Sep 17 00:00:00 2001 From: Dhaval Mehta <20968146+dhaval-mehta@users.noreply.github.com> Date: Tue, 23 Jun 2020 15:28:03 +0530 Subject: [PATCH 2/2] no need to pass context to get_serializer --- dj_rest_auth/views.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dj_rest_auth/views.py b/dj_rest_auth/views.py index a5d06d7..28b472d 100644 --- a/dj_rest_auth/views.py +++ b/dj_rest_auth/views.py @@ -105,8 +105,7 @@ class LoginView(GenericAPIView): def post(self, request, *args, **kwargs): self.request = request - self.serializer = self.get_serializer(data=self.request.data, - context=self.get_serializer_context()) + self.serializer = self.get_serializer(data=self.request.data) self.serializer.is_valid(raise_exception=True) self.login()