The issue is that if the database is allowed to sort results it sorts strings according to the C locale which yields awfully wrong results in my language. For example it considers all letters with diacritics to be after all ascii letters - so, for example, ś
comes after z
, while it should come in between s
and t
.
However, as long as I'm allowed to sort results in Python, I can easily tell Python how to sort according to the current locale. setlocale(LC_ALL, 'pl_PL.UTF-8')
and then set the key for sorting to be the result of strxfrm
applied to the model's string representation.
So, how can I force Django to sort results in Admin in Python and not in the database to circumvent the above issue?