to iterate over two lists simultaneously in *.html

2011-01-16 Thread gintare
Hello, I am sorry for asking a simple question. (I read other answer bout iteration in several items in this user group - they are too complicated for me. I have no time to study Django deeper. ) I want to iterate over two lists simultaneously in form which is simple (.html), do not described in m

Re: to iterate over two lists simultaneously in *.html

2011-01-16 Thread Masklinn
On 2011-01-16, at 09:25 , gintare wrote: > Hello, > > I am sorry for asking a simple question. > (I read other answer bout iteration in several items in this user > group - they are too complicated for me. I have no time to study > Django deeper. ) > I want to iterate over two lists simultaneously

Re: to iterate over two lists simultaneously in *.html

2011-01-16 Thread David Walker
As masklinn says, zip: http://docs.python.org/library/functions.html#zip Combine the two lists in python into one list of pairs (tuples). change the render_to_response line to: render_to_response(filter_obj.html', {'zipped': zip(obj1, obj2), 'q':query}) zip discards any elements that are left over

Re: to iterate over two lists simultaneously in *.html

2011-01-16 Thread Torsten Bronger
Hallöchen! David Walker writes: > [...] > > and the the {% for %} becomes: > {% for smth1, smth2 in zipped %} On the other hand, as somebody having zip() in a dozen of render_to_response calls, I can say that {% for smth1, smth2 in list1, list2 %} would be a nice thing to have. ;-) Tschö, To

Re: to iterate over two lists simultaneously in *.html

2011-01-16 Thread Masklinn
On 2011-01-16, at 14:42 , Torsten Bronger wrote: > Hallöchen! > > David Walker writes: > >> [...] >> >> and the the {% for %} becomes: >> {% for smth1, smth2 in zipped %} > > On the other hand, as somebody having zip() in a dozen of > render_to_response calls, I can say that > > {% for smth1,

Re: to iterate over two lists simultaneously in *.html

2011-01-16 Thread Torsten Bronger
Hallöchen! Masklinn writes: > On 2011-01-16, at 14:42 , Torsten Bronger wrote: > >> [...] >> >> On the other hand, as somebody having zip() in a dozen of >> render_to_response calls, I can say that >> >> {% for smth1, smth2 in list1, list2 %} >> >> would be a nice thing to have. ;-) > > Why d