You can’t just pass a string and reference it to an object of CustomUser
class. You’ll have to pass an instance of it.
First get the relevant instance by using id
or a suitable unique attribute,(hope the name
is unique)
def get_object(self, name):
return CustomUser.objects.get(name=name)
And then pass it in your save_message(self, name, message)
method,
def save_message(self, name, message):
user_obj = self.get_object(name)
Message.objects.create(name=user_obj, content=message)
CLICK HERE to find out more related problems solutions.