Reputation: 333
So I have two models: Article and Tag, and a m2m relationship which is properly set.
I have a route of the kind 'articles/tag/' and I would like to display only those articles related to that tag
I have sorted out this problem already but I am looking for a more elegant solution including pagination but I am not able to use paginate
over the articles list because it's not a queryset
I need a queryset of all articles linked to a certain tag. I have tried order_by
in many different ways and failed miserably.. I wasnt able to find something useful in the docs, any ideas?
Upvotes: 6
Views: 2047
Reputation: 4718
While OP's problem was lazy="dynamic"
, I ran into this issue with a relationship which was already using that. In my case, the problem turned out to be that I was using relationship()
imported directly from sqlalchemy.orm
. Instead, I needed to use db.relationship()
to get the version of the method wrapped by Flask-SQLAlchemy.
Upvotes: 1