How can I do multiple “order_by” in Flask-SQLAlchemy?

后端 未结 3 559
野性不改
野性不改 2021-02-03 16:58

Let\'s say I have a User model with fields popularity and date_created. I want to do the following query:

SELECT * FROM us         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-03 17:47

    This should work

    User.query.order_by(User.popularity.desc(),User.date_created.desc()).limit(10).all()
    

提交回复
热议问题