You can do that with a very simple template tag

register = template.Library()

@register.simple_tag
def get_element(list, index):
    # You should catch IndexError here.
    return list[index]


Template side:

{% get_element secondprice forloop.counter0 %}


Regards,
Martin Conte Mac Donell


>
> On Dec 17, 2007 3:06 PM, Greg < [EMAIL PROTECTED]> wrote:
>
> >
> > Hello,
> > I have the following in my template:
> >
> > {% for a in thespinfo %}
> > {{ secondprice.forloop.counter0|floatformat:2 }}
> > {% endfor %}
> >
> > However, nothing appears when I run this code
> >
> > ///////////////
> >
> > My secondprice variable contians a list like ['25', '14', '56'].  Each
> > time that my for loop is run through then I want to display that
> > current element in the secondprice element.  So the first time my loop
> > is run through then I want it to loop like:
> >
> > {{ secondprice.0|floatformat:2 }}...then next time like {{ secondprice.
> > 1|floatformat:2 }}...etc
> >
> >
> >
> > > >
> >
>

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