在用django框架中遇到一个错误,是模型编写中出的错误

TypeError: coercing to Unicode: need string or buffer, ChatRoom found

解决办法:

我的models.py文件:

TypeError: coercing to Unicode: need string or buffer, ChatRoom found

StackOverFlow上找到了回答:

 TypeError: coercing to Unicode: need string or buffer, ChatRoom found

因为我的ChartAccount 中room是外键,所以self.room 指向ChatRoom,不是一个string or buffer。

可改为self.room.name 或者去掉

相关文章: