django报错TypeError: __str__ returned non-string (type int)

原因

因为在models的__str__设置中,返回值是int类型

class Message(models.Model):
    ...省略...
    
    def __str__(self):
        return self.id

解决

返回值换一个字段,或者将此字段转换为字符串

class Message(models.Model):
    ...省略...
    
    def __str__(self):
        return str(self.id)
上一篇:CLI Mode (Command Line mode was called NON GUI mode),JMeter的CLI模式解析20210725


下一篇:centos mvn构建jar时候显示 al ssl失败 Non-resolvable parent POM for com : Could not transfer artifa