On 11/10/06, Jeremy Dunck <[EMAIL PROTECTED]> wrote: > > On 11/10/06, Merric Mercer <[EMAIL PROTECTED]> wrote: > > > > Jay, that works! Many thanks. Though I don't quite understand why - or > > where 'values' come from. Could you explain. > > .values is a standard method on dictionary objects which returns a > list containing the values in the dictionary in an undefined order.
An infact, I'd say that it's bad design to make your template author know about .views. Instead, you should just be passing a list from the view, not a dictionary, unless you actually need a dictionary, ie: return render_to_response ('myapp/detail.html', { 'key1': value1, 'key2': value2, 'campaigns':dict1.values()}) Then, in your template, you can do {% for item in campaigns %} {{item.id}} {% endfor %} Try playing around in the Python interpreter, to see the differences. In [4]: x = {"a":1, "b":2, "c":3} In [5]: x.keys() Out[5]: ['a', 'c', 'b'] In [6]: x.items() Out[6]: [('a', 1), ('c', 3), ('b', 2)] In [7]: x.values() Out[7]: [1, 3, 2] In [8]: for each in x: ...: print each ...: ...: a c b In [9]: for each in x: ...: print x[each] ...: ...: 1 3 2 The Python interpreter is one of the best weapons in any Pythonistas arsenal, learn to make it your best friend when coding. Jay P. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---