How to order by count of many-to-many relationship in SQLAlchemy?
问题 I'd like to order by the count of a many-to-many relationship on a table. My starting point was the (excellent) response to this thread. However, in my case, there is a third table involved and I need my backrefs to be 'joined' rather than 'dynamic'. The combination of those two changes results in ProgrammingErrors when I try the solution to that question. Here's my setup. I have the same many-to-many relationship between User and Post. I also have a one-to-many relationship between Post and