On Sat, 2008-02-02 at 20:42 -0600, Michael Hipp wrote: > I'm trying to do something in a template that seems really simple ... > populate the row/columns of a table and apply alignment for each field. > So I'm doing this: > > {% for row in report_data %} > <tr> > {% for col in row %} > <td align="{{ align.forloop.counter0 }}"> > {{ col }} > </td> > {% endfor %} > </tr> > {% endfor %} > > I'm trying to use the 'forloop.counter0' to get at which column I'm > currently populating so I can apply the appropriate alignment according > to the list contained in align. Align is a tuple of alignments: > > align = ("Center", "Right", "Left", "Center") > > So how does one actually make use of the forloop.counter0 variable?
By writing {{ align.forloop.counter0 }} you are actually asking for the "forloop" attribute on the "align" object and then the "counter0" attribute on that. Which isn't what you want. {{ forloop.counter0 }} is mostly for display purposes (displaying the index of a list) and testing (is it equal to 0 or whatever). > > Or is there some other way to get at my 'align' list? Look at the {% cycle %} template tag. It's designed for precisely this purpose. Regards, Malcolm -- No one is listening until you make a mistake. http://www.pointy-stick.com/blog/ --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---