On Thu, Jun 11, 2009 at 4:09 AM, 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 > > > > A lack of response on django-users is not a reason for sending something to -deveopers, this mailing listis strictly for the development of Django itself. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
