[Answered ]-Type Error: Field 'id' expected a number but got <User: ILador>

1👍

    def username(self):
        usern = User.objects.get(id=self.user) # <--
        usern = usern.username
        return usern

Here’s the error: self.user is an instance of User class, change this code line to use it’s id property usern = User.objects.get(id=self.user.id)

UPD: You probably don’t even need this .get(...) method, just:

    def username(self):
        return self.user.username
👤svfat

Leave a comment