I have the following code in index.html file and I am trying to sort the output A-Z.
Would it be possible by editing this code only?
{% for x in data.pairs %}
<option>{{ x }}</option>
{% endfor %}
I have the following code in index.html file and I am trying to sort the output A-Z.
Would it be possible by editing this code only?
{% for x in data.pairs %}
<option>{{ x }}</option>
{% endfor %}
I think you can do this.
{% for x in data.paris.all|dictsort:"variable name" %}
{{ x }}
{% endfor %}
Please follow the below mentioned documentation for details. Select your desire django version.
https://docs.djangoproject.com/en/dev/ref/templates/builtins/#std:templatefilter-dictsort
{% for x in data.pairs|sort %}
<option>{{ x }}</option>
{% endfor %}
This works perfectly