  from django.contrib.auth import authenticate
  
  from rest_framework import serializers
  from rest_framework.authtoken.models import Token
  
  
  class AuthTokenSerializer(serializers.Serializer):
      token = serializers.Field(source="key")
      username = serializers.CharField(max_length=30)
      password = serializers.CharField()
 
</s> remove     token = serializers.Field(source="key")
    username = serializers.CharField(max_length=30)
 </s> add     username = serializers.CharField() </s> remove class AuthTokenLoginView(CreateAPIView):
 </s> add class AuthTokenView(APIView):
    throttle_classes = ()
    permission_classes = ()
    parser_classes = (parsers.FormParser, parsers.MultiPartParser, parsers.JSONParser,)
    renderer_classes = (renderers.JSONRenderer,)  </s> remove from rest_framework.generics import CreateAPIView
 </s> add from rest_framework import status
from rest_framework import parsers
from rest_framework import renderers
from rest_framework.response import Response </s> remove                                     {'username': self.username, 'password': self.password})
        self.assertEqual(response.status_code, 201)
        self.assertEqual(json.loads(response.content)['token'], self.key)

    def test_token_logout(self):
        """Ensure token logout view using JSON POST works."""
        # Use different User and Token as to isolate this test's effects on other unittests in class
        username = "ringo"
        user = User.objects.create_user(username, "starr@thebeatles.com", "pass")
        token = Token.objects.create(user=user)
        auth = "Token " + token.key
        client = Client(enforce_csrf_checks=True)
        response = client.post('/auth-token/logout/', HTTP_AUTHORIZATION=auth)
 </s> add                                {'username': self.username, 'password': self.password}) </s> remove from django.http import HttpResponse
 </s> add 
  from django.contrib.auth import authenticate
  
  from rest_framework import serializers


  
  class AuthTokenSerializer(serializers.Serializer):
      token = serializers.Field(source="key")
      username = serializers.CharField(max_length=30)
      password = serializers.CharField()
keep keep keep replace replace keep keep keep keep keep
 Updates to login view for TokenAuthentication from feedback from Tom 
rest_framework/authtoken/serializers.py