Hi, I just wrote the following to switch between ascending and descending sort order in a table view:
view: columns = [ {'ABC' : u'abc'}, {'DEF' : u'def'}, {'GHI' : u'ghi'}, {'JKL' : u'jkl'} ] for column in columns: for column_title in column: if column[column_title] == sort_order: column[column_title] = u'-' + column[column_title] template: {% for column in columns %} {% for column_title, sort_criteria in column.iteritems %} <th><a href="{% url project.app.views.list sort_order=sort_criteria %}" target="_self">{{column_title}}</a></th> {% endfor %} {% endfor %} By embedding the hashpairs in an array (to keep the column order), I have to use a nested for loop in both the view and the template. I am sure there is a more elegant way to do this - could anyone point me in the right direction? Kind regards, Jan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---