SqlAlchemy - Filtering by Relationship Attribute

后端 未结 5 697
日久生厌
日久生厌 2020-12-07 13:09

I don\'t have much experience with SQLAlchemy and I have a problem, which I can\'t solve. I tried searching and I tried a lot of code. This is my Class (reduced to the most

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 13:18

    This is a more general answer on how to query relationships.

    relationship(..., lazy='dynamic', ...)
    

    This allows you to:

    parent_obj.some_relationship.filter(ParentClass.some_attr==True).all()
    

提交回复
热议问题