query = (
session.query(Post)
.join(Post.tags) # It's necessary to join the "children" of Post
.filter(Post.date_out.between(start_date, end_date))
# here comes the magic:
# you can filter with Tag, even though it was not directly joined)
.filter(Tag.accepted == 1)
)
免责声明:这是我实际代码的简化示例,在简化过程中可能会犯一个错误。
希望对您有所帮助。