Self-Referential Association Relationship SQLalchemy

后端 未结 4 1273
南笙
南笙 2020-12-17 03:39

In my flask application with flask-sqlalchemy i need to create association between two contact here is my Contact model

class Contact(db.Model):         


        
4条回答
  •  死守一世寂寞
    2020-12-17 04:08

    Your relationship is not correctly designed. A secondary should be an ordinary table, not a mapped class. If you want the extra data (relation_type) on your ContactRelation, you should use the Association Table pattern described in the SQLAlchemy Relationship docs: http://docs.sqlalchemy.org/en/rel_1_1/orm/basic_relationships.html#association-object

提交回复
热议问题