As I understand it, {{ foo }} renders the current value of the variable and doesn't change it. {% cycle foo %} or the creating {% cycle "odd" "even" as foo %} advance the variable and then render it. So you still need one of the latter in your loop, or the variable won't advance.
On Thu, Mar 25, 2010 at 5:43 PM, mhulse <rgmi...@gmail.com> wrote: > Hi Peter and Bill! Thanks for the quick replies, I really appreciate > it. :) > > @Peter: > > I tried this: > > ========== > > {% for foo, baz in tuple %} > ... > <div> > ... > {% cycle "odd" "even" as foo %} > {% for bar in baz %} > <li class="{{ foo }}">...</li> > ... > {% endfor %} > ... > </div> > ... > {% endfor %} > > ========== > > But the cycle "renders" the output and the variable "foo" does this: > > ========== > > <div><li ...odd...>...<li ...odd...>...<li ...odd...></div> > <div><li ...even...>...<li ...even...>...<li ...even...></div> > <div><li ...odd...>...</div> > > ========== > > Maybe I am not understanding the usage of the "as" part? > > @Bill: > > Ahhh! Hehe, that is tricky. :D > > I will experiment with your code sample. > > ... > > It just came to me... I can use "divisibleby"! > > This works: > > ========== > > <li class="{% if forloop.counter|divisibleby:"2" %}even{% else %}odd{% > endif %}"> > > ========== > > Django's version of the PHP modulo operator strikes again! > > Thanks again Peter and Bill, I really appreciate the help. Thanks for > taking the time to help a noob out. :D > > Cheers, > Micky > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > 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 django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.