Re: I have an idea for a new tag

2010-11-20 Thread ringemup
Is there a reason you wouldn't do the sorting in the view before passing it to the template? On Nov 19, 11:55 am, Paweł Roman wrote: > When rendering dictionary, there is absolutely no way to display > values sorted by keys. The only workaround is to copy all the dict > items to a sortable struc

Re: I have an idea for a new tag

2010-11-20 Thread Łukasz Rekucki
On 19 November 2010 19:53, Adam Hallett wrote: > Just a thought, what about: > > {% for k,v in mydict|order:'key' %} > > or > > {% for k,v in mydict orderby key %} Here's a quick hack that works right now: {% for k, v in mydict.items|dictsort:"0" %} {{ k }}: {{ v }} {% endfor %} > On Nov 19,

Re: I have an idea for a new tag

2010-11-19 Thread Adam Hallett
Just a thought, what about: {% for k,v in mydict|order:'key' %} or {% for k,v in mydict orderby key %} -Adam On Nov 19, 10:55 am, Paweł Roman wrote: > When rendering dictionary, there is absolutely no way to display > values sorted by keys. The only workaround is to copy all the dict > items

Re: I have an idea for a new tag

2010-11-19 Thread Doug
An easy alternative is to make a sort filter: register.filter('sort',lambda x: sorted(x)) and then do {% for k,v in mydict.items|sort %} {{k}}:{{v}} {% endfor %} I had to look at the docs to realize there isn't a sort filter in django for some reason. I long ago added the one above to built