Flask-Web-App-Tutorial icon indicating copy to clipboard operation
Flask-Web-App-Tutorial copied to clipboard

Order by Note.date desc

Open vzshan opened this issue 2 years ago • 0 comments

How can we order the Notes by date in desc in view.home? Is there a better way to sort Note in current_user.Note object and return user=current_user back to home page instead.

Currently I am doing like below to return Notes object back to home age, and from home page loop Note object to get the data in desc order:-

notes=Note.query.filter_by(user_id=current_user.id).order_by(desc(Note.date))
return render_template("home.html", user=current_user, notes=notes)

vzshan avatar Nov 04 '22 07:11 vzshan