Flask中SQLAlchemy出错:AmbiguousForeignKeysError: Could not determine join condition between parent/child tables on relationship

参考文章:https://www.crifan.com/flask_sqlalchemy_amibiguousforeignkeyserror_could_not_determine_join_condition/

【总结】

当一个表中出现多个:ForeignKey 则SQLAlchemy无法识别,具体哪个属性,从哪个去找,所以报错:
AmbiguousForeignKeysError: Could not determine join condition between parent/child tables on relationship Task.initiator

解决办法:
给db.relationship添加foreign_keys,就可以指明具体是哪个属性了。

你可能感兴趣的:(Flask中SQLAlchemy出错:AmbiguousForeignKeysError: Could not determine join condition between parent/child tables on relationship)