Answer the question
In order to leave comments, you need to log in
How to sort by DateTimeField but only by date (django)?
There is a field DateTimeField.
It is necessary to sort so that time is not taken into account.
As a result, you need to sort the result by date, and then by rating. If time is taken into account in this sorting, then sorting by rating will be meaningless
Answer the question
In order to leave comments, you need to log in
Foo.objects.extra(select={'d_field': 'date(<field name>)'}).extra(order_by=['d_field'])
Since version 1.9 you can do this:
Bar.objects.all().order_by('my_date_time_field__date')
prooflink: https://docs.djangoproject.com/en/dev/ref/models/q...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question