0

I want to Display my List name in alphabetical order {{ name }}

Philip
Bosson
Alivio

i.e I want to make it like

Alivio
Bosson
Philip

Help appreciated!!!

Swati
  • 2,870
  • 7
  • 45
  • 87

1 Answers1

0

Use the sorted command to generate the list.

sorted(["Philip","Bosson","Alivio"])  

You probably want to do this in the view then pass it in the context down to the html template.

More details with this post: enter link description here

Then in django template

{% for name in sorted_list %} {{name}} {%endfor %}
sahutchi
  • 2,223
  • 2
  • 19
  • 20