The problem is that when using order_by()
, Ukrainian letters are incorrectly sorted alphabetically, that is, before "а", "б" is placed "і" and "є".
Changing the column encoding to utf8mb4_unicode_ci
helped me.
PS. Failed to change the encoding of the entire database or table. Only the column.
But later it turned out that this was not enough for me. I need to sort addresses that contain letters and numbers. In the end I was able to do it the way I needed with Natsort
from natsort import humansorted
import locale
locale.setlocale(locale.LC_ALL, 'uk_UA.UTF-8')
objects = humansorted(objec, key=lambda p: p.address)