Hi Tom, SortedDict(yourdict) is a hard thing and takes a lot of tinkering? don't you have python 2.4 to use sorted(dict.iteritems())? can't write your own python function to do this in your views side?
next, |dictsort:"0" is working for at least two years and is pretty stable functionality. even if it will suddenly stop working -- you can take any dictsort implementation and put it to your templatetags folder. is it not acceptable? next, documenting issue. please add a trac issue to document this behavior, suggest your documentation. it's working well, people is using it, it's listed at some recipes blogs, no important related bugs found. why should one attempt to remove or change this feature? you seems to be very curious about a merely meaningless question. of course nobody knows about it a lot, nobody cares a lot, and of course by the nature of group discussion nobody is answering. On Thu, Jun 11, 2009 at 4:09 PM, Tom Evans<[email protected]> wrote: > > On Wed, 2009-06-10 at 06:54 -0700, Adrian Rogers wrote: >> On Jun 9, 11:09 am, Tom Evans <[email protected]> wrote: >> > Hi all >> > >> > I was struggling to turn a typical template dictionary iteration use >> > case into a sorted dictionary iteration, and struggling to find any way >> > of managing it. >> > >> > Eg: >> > >> > {% for key, val in tdict.items %}....{% endfor %} >> > >> > After perusing docs, and the internet, it seemed like there was no >> > straightforward way to manage to turn this into a sorted dictionary >> > iteration, apart from altering the data structure outside the template. >> > >> > Finally, we looked at the source code for the dictsort filter, and it >> > seems like this would work to produce the desired result: >> > >> > {% for key, val in tdict.items|dictsort:"0" %}....{% endfor %} >> > >> > and, indeed, it does the trick. >> > >> > However, the documentation for dictsort indicates that it is for sorting >> > lists of dictionaries, and this behaviour seems to happen by >> > coincidence. If I use this construct, is it likely to fail in the >> > future, or is this actually intended usage? >> > >> > Cheers >> > >> > Tom >> >> That's really cool, I've been looking for something like that for ages >> and always had to tinker around with my data structures before putting >> them into the template. Anyone able to confirm if this is an intended >> use that I can rely on for the future? >> >> -- >> Adrian >> > > Can anyone comment on this? Sorry to bring it up in -developers, but > no-one will comment on it in -users. > > Cheers > > Tom > > > > -- Best regards, Yuri V. Baburov, ICQ# 99934676, Skype: yuri.baburov, MSN: [email protected] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---
