equality expressions involving locally mapped foreign key columns for primary join condition 'storage_binding.object_id = :object_id_1' on relationship Doctor.media_m2m. Ensure that referencing columns are associated with a ForeignKey or ForeignKeyConstraint, or are annotated in the join condition with the foreign() annotation. To allow comparison operators other than '==', the relationship can be marked as viewonly=True.
class StorageBinding(Base, UUIDMixin):
__tablename__ = 'storage_binding'
content_type_id = Column(Integer, FK('django_content_type.id'))
object_id = Column(UUID(as_uuid=True))
resource_id = Column(UUID(as_uuid=True), FK('storage_resource.id'))
resource = relationship('StorageResource', backref='resources')
class Doctor(Base, UUIDMixin):
media_m2m = relationship(
StorageBinding,
primaryjoin=(id == foreign(StorageBinding.object_id)))
media = relationship(
StorageResource, secondary=StorageBinding.__tablename__,
lazy='subquery')
media_m2m судя по названию там должен быть secondary, не?
а где у доктора id?
я чет запутался кто на кого ссылается, тут не должно бы FK?
а не катит так? media_m2m = relationship( StorageBinding, primaryjoin=(Doctor.id == StorageBinding.object_id) )
Обсуждают сегодня