[Answered ]-Getting "AuthToken.user" must be a "User" instance. in django-rest-knox

1👍

In this part of your code :

 return Response({
        "user": UserSerializer(user, context=self.get_serializer_context()).data,  # Get serialized User data
        "token": token
    })

You need to replace the token by an instance of the user on which this token belong so for example :

 return Response({
            "user": UserSerializer(user, context=self.get_serializer_context()).data,  # Get serialized User data
            "token": User.objects.get(token=token)
        })

Leave a comment