On Sun, Feb 15, 2009 at 2:47 PM, nivhab <yaniv.ha...@gmail.com> wrote:
> > Does anyone know of a way to traverse a list in templates in a dynamic > way? > Let's say I have the following list: > {'message': [u'This field is required.'], 'sender': [u'Enter a valid e- > mail address.']} > > and I do not know in advance the keys for this list. I would like to > iterate through it and display its content (keys and values) in a > dynamic way in a template. Can it be done? > > Thanks in advance! > > > > First of all that's not a list, it's a dictionary, but you can iterate over a dictionary just as easily: {% for key, value in dictionary %} {{ key }}: {% for v in value %} {{ v }}{% endfor %} {% endfor %} -- "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 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 -~----------~----~----~----~------~----~------~--~---