aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/authtoken/views.py
diff options
context:
space:
mode:
authorTom Christie2014-09-02 17:41:23 +0100
committerTom Christie2014-09-02 17:41:23 +0100
commitf2852811f93863f2eed04d51eeb7ef27716b2409 (patch)
tree45799932849f81d45d77edc53cb00269465ba0f1 /rest_framework/authtoken/views.py
parentec096a1caceff6a4f5c75a152dd1c7bea9ed281d (diff)
downloaddjango-rest-framework-f2852811f93863f2eed04d51eeb7ef27716b2409.tar.bz2
Getting tests passing
Diffstat (limited to 'rest_framework/authtoken/views.py')
-rw-r--r--rest_framework/authtoken/views.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/rest_framework/authtoken/views.py b/rest_framework/authtoken/views.py
index 7c03cb76..94e6f061 100644
--- a/rest_framework/authtoken/views.py
+++ b/rest_framework/authtoken/views.py
@@ -18,7 +18,8 @@ class ObtainAuthToken(APIView):
def post(self, request):
serializer = self.serializer_class(data=request.DATA)
if serializer.is_valid():
- token, created = Token.objects.get_or_create(user=serializer.object['user'])
+ user = serializer.validated_data['user']
+ token, created = Token.objects.get_or_create(user=user)
return Response({'token': token.key})
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)