0
I wanted to order DateTimeField by date only, ignoring the time.
Because in my ordination I need to
Person.objects.order_by('-date_joined', 'full_name')
But sorting by name has no effect because the field has time, but I only wanted the date.
0
I wanted to order DateTimeField by date only, ignoring the time.
Because in my ordination I need to
Person.objects.order_by('-date_joined', 'full_name')
But sorting by name has no effect because the field has time, but I only wanted the date.
1
Try using the . extra
resultado = Person.objects.extra(select =
{'date_only': 'to_date(date_joined)'}).order_by('-date_only', 'fullname')
Browser other questions tagged django classification
You are not signed in. Login or sign up in order to post.
has already been answered here http://stackoverflow.com/a/38151686/802542 Thank you.
– Regis Santos