flask sqlalchemy多对多绑定出现问题

RIOChing

关注

阅读 76

2022-01-12

sqlalchemy.exc.ArgumentError: secondary argument <class ‘orm框架.model.models.StudentTohobby’> passed to to relationship() Hobby.srelate_many_hobby must be a Table object or other FROM clause; can’t send a mapped class directly as rows in ‘secondary’ are persisted independently of a class that is mapped to that same table.

多对多可以在任意一个类中加relationship(secondary="");
将secondary 参数改成对应 tablename 值就可以了不要写对应的model类;

精彩评论(0)

0 0 举报