2014-05-09 33 views
0

這是使用燒瓶安全我第一次,我似乎無法成功創建用戶。燒瓶安全錯誤「User對象有沒有屬性的角色

每次我嘗試,我得到一個」用戶對象有沒有屬性的角色」錯誤

下面是相關代碼: 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. 

回答

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')) 
相關問題