Ordering a Django QuerySet by a datetime's month/day?

前端 未结 5 602
太阳男子
太阳男子 2021-01-02 16:00

I have a list of people, each person having a birthdate, which is predictably stored in a DateField. I\'m trying to create a list of those people—sorted by the

5条回答
  •  孤街浪徒
    2021-01-02 16:44

    Post.objects.all().order_by('date_posted__minute').reverse() where date_posted is your attribute you used in your Post model.

    Post is just an example model

提交回复
热议问题