title: Django rest framework Logout and Login View don't work
body: <p>I'm doing a user registration via email with email confirmation. Then user gets a email letter to activate and finish its registration, login methods works. But I cant logout that user, and log him again. Could you suggest any other methods got logout and login with similar register View.</p>
  
  <p>Here is my RegisterView, that works good.</p>
  
  <pre class="lang-py prettyprint-override"><code>class RegisterView(APIView):
      permission_classes = [AllowAny]
      def post(self, request, *args, **kwargs):
          email = request.data.get('email', False)
          password = request.data.get('password', False)
          role = request.data.get('role')
          if email and password and role:
              user = User.objects.filter(email=email)
              if user.exists():
                  return JsonResponse('Такой email уже существует', safe=False)
              else:
                  temp_data = {
                      'email': email,
                      'password': password,
                      'role': role
                  }
                  serializer = CreateUserSerializer(data=temp_data)
                  serializer.is_valid(raise_exception=True)
                  user.is_active = False
                  user = serializer.save()
                  # user = authenticate(request, email=email, password=password)
                  user.set_password(user.password)
                  user.save()
  
                  current_site = get_current_site(request)
                  print(current_site)
                  subject = 'Activate Your MySite Account'
                  message = render_to_string('account_activation_email.html', {
                      'user': user,
                      'domain': current_site.domain,
                      'uid': urlsafe_base64_encode(force_bytes(user.pk)),
                      'token': account_activation_token.make_token(user),
                  })
                  print(message)
                  from_email = settings.EMAIL_HOST_USER
                  to_email = serializer.validated_data.get('email')
                  email = EmailMessage(
                      subject, message, from_email, to=[to_email],
                  )
                  print(email)
                  email.send()
                  # return Response(serializer.data, status=status.HTTP_201_CREATED)
                  return HttpResponse('Please confirm your email address to complete the registration')
  
          else:
              return JsonResponse('Email не указан', safe=False)
  
  </code></pre>
  
  <p>Here is function for registration activating</p>
  
  <pre class="lang-py prettyprint-override"><code>def activate(request, uidb64, token):
      try:
          uid = force_text(urlsafe_base64_decode(uidb64))
          user = User.objects.get(pk=uid)
      except(TypeError, ValueError, OverflowError, User.DoesNotExist):
          user = None
      if user is not None and account_activation_token.check_token(user, token):
          user.is_active = True
          user.set_password(user.password)
          user.save()
  
          login(request, user)
          return HttpResponse('Thank you')
      else:
          return HttpResponse('Activation link is invalid!')
  
  </code></pre>
  
  <p>But my logout and login views dont work </p>
  
  <pre class="lang-py prettyprint-override"><code>class LogoutView(APIView):
      authentication_classes = [TokenAuthentication]
      permission_classes = [IsAuthenticated,]
  
      def post(self, request):
          # django_logout(request)
          request.user.auth_token.delete()
  
          return Response(status=204)
  class LoginView(KnoxLoginView):
      permission_classes = (AllowAny,) #условие, если email не подтвержден, не поулчится залогиниться
      def post(self, request, format=None):
          serializer = LoginSerializer(data=request.data)
          serializer.is_valid(raise_exception=True)
          user = serializer.validated_data['user']
          # token, created = Token.objects.get_or_create(user=user)
          # return Response({"token": token.key, 'id': token.user.id}, status=200)
          login(request, user)
          return super().post(request, format=None)
  </code></pre>
  
  <pre class="lang-py prettyprint-override"><code>class LoginSerializer(serializers.Serializer):
      email = serializers.EmailField()
      password = serializers.CharField(style={'input_type': 'password'}, trim_whitespace=False)
  
      def validate(self, data):
          email = data.get('email')
          print(email)
          password = data.get('password')
          if email and password:
              if User.objects.filter(email=email).exists():
                  print(email, password)
  
                  user = authenticate(request=self.context.get('request'), email=email, password=password)
                  print(user)
              else:
                  msg = {
                      'status': False,
                      'detail': 'Email is not found'
                  }
                  raise serializers.ValidationError(msg)
  
              if not user:
                  msg = {
                      'status': False,
                      'detail': 'Эмейлы не совпадают'
                  }
                  raise serializers.ValidationError(msg, code='authorization')
  
          else:
              msg = {
                  'status': False,
                  'detail': 'Email is not found in request'
              }
              raise serializers.ValidationError(msg, code='authorization')
  
          data['user'] = user
          return data
  </code></pre>