级联从拥有的父级变为要删除的子级对象,因此User.user_to_groups,Group.group_to_user:
class UserToGroup(base): __tablename__ = 'user_to_group' user_login = Column(String(60), ForeignKey(User.login), primary_key=True) group_name = Column(String(100), ForeignKey(Group.name), primary_key=True) user = relationship(User, backref=backref('user_to_groups', cascade='all, delete-orphan')) group = relationship(Group, backref=backref('group_to_user', cascade='all, delete-orphan'))
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)