得到错误“ rel_model”的意外值预期的“ Model”,“ Proxy”,“ DeferredRelation”或“ self”

时间:2018-10-22 04:36:45

标签: python peewee flask-peewee

我有以下课程

class User(db.Model, UserMixin):
    user = peewee.CharField(max_length=255)
    email = peewee.CharField(max_length=256)

class UserRoles(db.Model):
    user = peewee.ForeignKeyField(User, related_name="roles")

我有export FLASK_APP=run.py 所以当我从终端运行flask create_user(测试用户)时,我得到了错误提示:

Unexpected value for "rel_model" Expected "Model", "Proxy", "DeferredRelation", or "self"

1 个答案:

答案 0 :(得分:0)

尝试将userMixin作为第一类,然后将db.Model作为第二类。多继承在Python中有点奇怪。