【问题标题】:How to resolve sqlalchemy.exc.NoForeignKeysError?如何解决 sqlalchemy.exc.NoForeignKeysError?
【发布时间】:2021-01-09 06:52:31
【问题描述】:

这是错误:

sqlalchemy.exc.NoForeignKeysError
sqlalchemy.exc.NoForeignKeysError: Could not determine join condition between parent/child tables on relationship User.posts - there are no foreign keys linking these tables.  Ensure that referencing columns are associated with a ForeignKey or ForeignKeyConstraint, or specify a 'primaryjoin' expression.

请看图片。

【问题讨论】:

  • "这里不知道怎么正确上传问题。" - 请参阅How to Ask

标签: sqlalchemy


【解决方案1】:

您在class User 中错过了db

posts=relationship("BlogPost", back_populates='auther')

改正

posts=db.relationship("BlogPost", back_populates='auther')

【讨论】:

    猜你喜欢
    • 2021-07-18
    • 1970-01-01
    • 2019-12-05
    • 2017-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-26
    • 2018-06-01
    相关资源
    最近更新 更多