This is one of those things that just isn't exceptionally straightfoward to accomplish.

From within a template, and without extensions, I can't think of how you would do that immediately. It sounds like you have a relatively simple set of data, so I'd recommend instead on "tweaking" the data you have in the view prior to sending it to the template to be rendered.

Within the view, loop through your values for "b" that match up with each of the transfers, and assign a new variable (maybe "b") to each transfer as you go through the list - then you can reference it in the one loop:

{% for cash in transfers %}
...
<td>{{ cash.credit }}</td>
<td>{{ cash.debit }}</td>
<td>{{ cash.b }}</td>
{% endfor %}


There are a couple of other references for how to display tabular data, both of which boil down to extending the tags - either with a TemplateTag or a Filter.

-joe

On 10/31/06, Merric Mercer <[EMAIL PROTECTED]> wrote:

As a newbie to Python, I can't see how one can nest two loops within a
template.  Taking the template below, I have an additional list which I
need to iterate over  in order to display a single figure for the last
cell in each table row.

Currently, if I add a for loop to the last cell (eg.  {% for b in
balance %} {{ b }} {% endfor %} ), I get all the values of the list in
the cell - which is not want I want.

The documentation mentions a forloop.parentloop but I'm not sure  how to
apply this or whether it is the solution.   Can anybody help?

MerMer

<table>
{% for cash in transfers %}
<tr>
<td>{{ cash.date }}</td>
<td>{{ cash.source }}</td>
<td>{{ cash.credit }}</td>
<td>{{ cash.debit }}</td>
<td>  {{ b }} </td>

{% endfor %}
</table>




--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to