Answer the question
In order to leave comments, you need to log in
How to order list items case insensitively?
You need to sort alphabetically regardless of case. Those. "B" should not be higher than "a". I know that uppercase codes come before lowercase ones, so the sorting itself needs to be done in lowercase.
I read in the documentation about the following method:
from django.db.models.functions import Lower
Article.objects.order_by(Lower('name').asc())
Answer the question
In order to leave comments, you need to log in
As an option:
Article.objects.extra(select={'name_lower': 'LOWER(name)'}).order_by('name_lower')
You can try through annotate, then order_by.
https://docs.djangoproject.com/en/1.11/topics/db/a...
Something like Article.objects.annotate(name_lower=Lower('name')).order_by('name_lower')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question