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
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
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
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
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,
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
6 matches
Mail list logo