pythondjangosorting

django order_by query set, ascending and descending


How can I order by descending my query set in django by date?

Reserved.objects.all().filter(client=client_id).order_by('check_in')

I just want to filter from descending all the Reserved by check_in date.


Solution

  • Reserved.objects.filter(client=client_id).order_by('-check_in')
    

    Notice the - before check_in.

    - before column name mean "descending order", while without - mean "ascending".

    Django Documentation