Querying a many-to-many relationship in SQLAlchemy

前端 未结 1 1524
一整个雨季
一整个雨季 2020-12-14 10:28

I have a pretty standard many-to-many relationship, similar to the Blog -> Keyword relationship in the ORM tutorial.

I would like to query for a list of Keywords, re

相关标签:
1条回答
  • 2020-12-14 10:47

    I think you just want

    .filter(Blog.keywords.any(Keyword.name.in_(['keyword1', 'keyword2', ...])))
    

    I'm using http://www.sqlalchemy.org/docs/05/ormtutorial.html#common-filter-operators for reference

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