这是我第一次使用Flask-Security,我似乎无法成功创建用户。
每次尝试时,我都会收到“用户对象没有属性角色”错误。
以下是相关代码: https://gist.github.com/ianseyer/f08d3f47471588e79022
修改
意识到这可能是因为我没有__tablename__ = 'roles'
,但这给了我这个错误:
sqlalchemy.exc.ArgumentError: Could not determine join condition between parent/child tables on relationship User.role. Specify a 'primaryjoin' expression. If 'secondary' is present, 'secondaryjoin' is needed as well.
答案 0 :(得分:1)
您已将其称为role
。改变
role = db.relationship('Role', secondary=roles_users, backref=db.backref('users', lazy='dynamic'))
到
roles = db.relationship('Role', secondary=roles_users, backref=db.backref('users', lazy='dynamic'))