I want to display a list of objects in a Django generic display view ListView
class. And, to make it prettier, I try to sort it in alphabetic order. So, I use the built-in dictsort
tag to sort the list.
Here is the summary of the code I used:
{% for item in object_list|dictsort:"name" %}
...
{% empty %}
...
{% endfor %}
The problem is that it sorts the names according to the ASCII values of the characters, meaning that bigcaps and smallcaps are sorted differently. Here is an example:
Bob
Eve
alice
zoe
And, what I would like to have is the following:
alice
Bob
Eve
zoe
I looked the documentation and several questions in SO, with no success. So, if someone has a way to achieve this, I would be extremely grateful.
for
loop. And, second, how would you get the DB to return the sorted list from the template ? – Macbeth