You need to sum the fines before you enter the templates.

This can be done either in your view like this:
    total_fines = sum([item.fine for item in items])

Or you can do it in the db using the 'Sum' aggregate, see
http://docs.djangoproject.com/en/dev/ref/models/querysets/#sum

Regards
Knut

On Sun, Nov 7, 2010 at 12:32 AM, Michael Sprayberry
<[email protected]> wrote:
>
> Hello,
>     I am not sure if this is what you are looking for but you can use a 
> forloop.counter (index to 1) or a forloop.counter0 (index at 0) from within 
> the template {% for loop %}
>
>
> Michael
>
> Hi,
> In a django template I have a for loop that display (item, fine). I
> would like to compute the total fine value at the end of the for loop.
> Is it possible to compute the total in the template? How can I do it
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to [email protected].
> 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.
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to [email protected].
> 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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
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.

Reply via email to