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()