  from django.http import HttpResponse
  
  class AuthTokenLoginView(CreateAPIView):
      model = Token
      serializer_class = AuthTokenSerializer
  
  
  class AuthTokenLogoutView(APIView):
      def post(self, request):
          if request.user.is_authenticated() and request.auth:
 
</s> remove 
class AuthTokenLogoutView(APIView):
 </s> add  </s> remove         if request.user.is_authenticated() and request.auth:
            request.auth.delete()
            return HttpResponse("logged out")
        else:
            return HttpResponse("not logged in")
    
 </s> add         serializer = AuthTokenSerializer(data=request.DATA)
        if serializer.is_valid():
            token, created = Token.objects.get_or_create(user=serializer.object['user'])
            return Response({'token': token.key})
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
 </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 django.http import HttpResponse
 </s> add  </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
  from django.http import HttpResponse
  
  class AuthTokenLoginView(CreateAPIView):
      model = Token

  
  
  class AuthTokenLogoutView(APIView):
      def post(self, request):
          if request.user.is_authenticated() and request.auth:
keep keep keep keep replace keep keep keep keep keep
 Updates to login view for TokenAuthentication from feedback from Tom 
rest_framework/authtoken/views.py