How can I do multiple "order_by" in Flask-SQLAlchemy?
This should work
User.query.order_by(User.popularity.desc(), User.date_created.desc()).limit(10).all()
What you also could do:
from sqlalchemy import and_, or_User.query.order_by(and_(User.popularity.desc(), User.date_created.desc())).all()
Note: and_
and or_
are coming from the sqlalchemy library and not from flask_sqlalchemy library.sqlalchemy is a dependency for flask_sqlalchemy, so you should be good.
LTS: You can mix sqlalchemy lib with flask_alchemy lib
I have another example:
user = User.query.order_by(User.id.desc()).limit(10).all()s.t
User is my class db.Modle