What is wrong with my relationships in SQL Alchemy?

后端 未结 2 1171
无人共我
无人共我 2021-02-05 10:34

I am using SQLAlchemy with Flask to create relationships for my application. I recently rewrote the relationships, and, no matter what I change, I keep getting the error:

2条回答
  •  忘了有多久
    2021-02-05 11:23

    Try to use primaryjoin in your CurriculumVersion class as follows:

    Change

    enrollments = db.relationship('Enrollment', backref='enrollment', lazy='dynamic')
    

    to

    enrollments = db.relationship('Enrollment', backref='enrollment', lazy='dynamic', primaryjoin="Enrollment.version_id==CurriculumVersion.id")
    

    Note: You might need to do this for the other classes as well.

提交回复
热议问题