Django sorting by date returns wrong sorting order

I have a query like this:

Pedido.objects.filter(...).aggregate(...).values('dia_pedido').annotate(...).order_by('dia_pedido')

The field 'dia_pedido' is of Date type. Data is not being displayed in the correct order:

(...)
25/08/2022

26/08/2022

30/08/2022

01/09/2022

02/09/2022

28/06/2022

30/06/2022

01/07/2022

The last 3 lines above shouldn't be there, as June and July come before August and September. What could be happening?

I'm using Django 4.0.1 and MySQL 8.0.30.

think mistake in type of date, mb american variant

Back to Top