I'm currently following the Django guide and using the receiver to assign an auth token. However, the following retuens the error
Cannot assign "<User: User object>": "Token.user" must be a "User" instance.
##PRE CREATE Method
@receiver(post_save, sender=User)
def create_auth_token(sender, instance=None, created=False, **kwargs):
if created:
Token.objects.create(user=instance)
class UserViewSet(viewsets.ModelViewSet):
queryset = User.objects.all()
serializer_class = UserSerializer
Even replacing the @receiver
with does not work
def perform_create(self, serializer):
user = serializer.save()
Token.objects.create(user=user)