Error on join condition with SqlAlchemy

后端 未结 1 661
野性不改
野性不改 2021-01-24 08:01

I\'m trying to use SQLAlchemy on my python app but I have a problem with the many to many relationship. I have 4 tables:

users, flags, commandes, channels, and commandes

相关标签:
1条回答
  • 2021-01-24 08:30

    back_populates needs to match the exact name of the related property on the other model. In Channel, you have back_populates="channels", but in Commande, you have:

    channel = relationship("Channel", secondary="commandes_channels_flags", back_populates="commandes")
    

    Instead, change channel = relationship to channels = relationship.

    You'll also need to change the other relationship properties to Flag.commandes, Flag.channels, Channel.commandes, Channel.flags, and Commande.flags to match your back_populates arguments.

    0 讨论(0)
提交回复
热议问题