From 51bca111c2e7dbb011ddb14bade99bdf323c1a14 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Mon, 4 Jun 2018 17:18:52 +0100 Subject: [PATCH] Fix the link between objects and subjects. --- sourcing/model.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sourcing/model.py b/sourcing/model.py index 6a2a145..e2cf5fc 100644 --- a/sourcing/model.py +++ b/sourcing/model.py @@ -140,13 +140,15 @@ class Item(TimeStampedModel): text = Column(UnicodeText) subjects = relationship('Item', + lazy='dynamic', secondary='reference', - backref='object_item', - foreign_keys=Reference.subject_id) + primaryjoin=id == Reference.object_id, + secondaryjoin=id == Reference.subject_id) objects = relationship('Item', + lazy='dynamic', secondary='reference', - backref='subject_item', - foreign_keys=Reference.object_id) + primaryjoin=id == Reference.subject_id, + secondaryjoin=id == Reference.object_id) user = relationship('User', backref='items') __mapper_args__ = {