Can I force Django to sort admin results in Python rather than in the database? -
the issue if database allowed sort results sorts strings according c locale yields awfully wrong results in language. example considers letters diacritics after ascii letters - so, example, ś comes after z, while should come in between s , t.
however, long i'm allowed sort results in python, can tell python how sort according current locale. setlocale(lc_all, 'pl_pl.utf-8') , set key sorting result of strxfrm applied model's string representation.
so, how can force django sort results in admin in python , not in database circumvent above issue?
as commenter pointed out, getting collation in database set seems more appropriate solution, since databases made these type of things in performant manner (sorting, ordering, etc.).
however, if prefer in python, override get_queryset method in admin class, , put whatever code want in there, shown in the docs.
Comments
Post a Comment