From 646d8c34e26c7f318cc2c4b3b1e58b953328985d Mon Sep 17 00:00:00 2001 From: Ivan Feofanov Date: Thu, 26 Apr 2018 12:47:08 +0500 Subject: [PATCH] Swith to native DRF exception handling To use the DRF exception handler --- rest_framework_expiring_authtoken/views.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rest_framework_expiring_authtoken/views.py b/rest_framework_expiring_authtoken/views.py index dc7fc97..779e9bc 100644 --- a/rest_framework_expiring_authtoken/views.py +++ b/rest_framework_expiring_authtoken/views.py @@ -21,7 +21,7 @@ def post(self, request): """Respond to POSTed username/password with token.""" serializer = AuthTokenSerializer(data=request.data) - if serializer.is_valid(): + if serializer.is_valid(raise_exception=True): token, _ = ExpiringToken.objects.get_or_create( user=serializer.validated_data['user'] ) @@ -36,6 +36,4 @@ def post(self, request): data = {'token': token.key} return Response(data) - return Response(serializer.errors, status=HTTP_400_BAD_REQUEST) - obtain_expiring_auth_token = ObtainExpiringAuthToken.as_view()