问题描述
所以我试图为我的项目创建种子文件,它涉及两个 association objects(关联表是连接表,除了外键之外还有额外的数据,如果我理解正确的话)。但是,我不太确定如何设置种子文件的关联,因为我无法像文档中的示例那样说出父子关系。
基本布局:
class User(db.Model):
__tablename__ ='users'
... columns here
events = db.relationship('Prediction',back_populates='users')
comments = db.relationship('Comment',back_populates='users')
class Event(db.Model):
__tablename__='events'
...columns here
users = db.relationship('Prediction',back_populates='events')
comments = db.relationship('Comment',back_populates='events')
class Prediction(db.Model):
__tablename__ = 'predictions'
...Columns here (user_id,event_id,choice,probability)
user = db.relationship('User',back_populates='events')
event = db.relationship('Event',back_populates='users')
class Comment(db.Model):
__tablename__ = 'comments'
...Columns here (user_id,comment)
user = db.relationship('User',back_populates='users')
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)