【问题标题】:Flask-Security error "User object has no attribute roles'Flask-Security 错误“用户对象没有属性角色”
【发布时间】:2014-06-27 01:26:38
【问题描述】:

这是我第一次使用 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.

【问题讨论】:

    标签: flask sqlalchemy flask-sqlalchemy flask-security


    【解决方案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'))
    

    【讨论】:

      猜你喜欢
      • 2020-06-25
      • 2012-06-24
      • 2018-02-02
      • 2021-02-08
      • 2018-10-30
      • 1970-01-01
      • 2014-12-23
      • 2017-01-24
      • 1970-01-01
      相关资源
      最近更新 更多