I have two related objects: Post and Comment. One Post can have many Comments. Im using backref so I can reference comment list from post object:
post = Post.query.get(post_id)
all_comments = post.comments # returns all comments of whole post
Now I want to filter those comments by their author. I want to be able to do something like this:
post.comments.filter(author_id=author_id)
In Django I did it like this:
post.comments.all().filter(author_id=author_id)
But in Flask I can't figure it out. I don't to query all database using:
Comment.query.filter_by(post_id=post_id, author_id=author_id)
How do I do that query?