X
X
Xymis2020-08-19 13:50:21
Flask
Xymis, 2020-08-19 13:50:21

How to correctly compose a flask sqlalchemy sort query?

Hello
I have a Model that has a one-to-many relationship with another Model. Article and comments
Article.query.first().comments - will return an InstrumentedList that has access to len()
You need to write Article.query.order_by() with an argument such that you get a sequence sorted by the number of comments on the article. Please help, thanks in advance!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question