Django date query from newest to oldest

后端 未结 2 1618
北恋
北恋 2021-02-19 09:27

I am building my first Django program from scratch and am running into troubles trying to print out items to the screen from newest to oldest. My model has an auto date time fie

2条回答
  •  情深已故
    2021-02-19 09:48

    By the way you also have Django's created_at field at your disposal:

    ordered_tasks = TaskItem.objects.order_by('-created_at')
    

提交回复
热议问题