On 12 déc, 11:57, Daniel Roseman <roseman.dan...@googlemail.com>
wrote:
> On Dec 12, 7:04 am, "Haroon idrees" <haroo...@gmail.com> wrote:
>
>
>
> > Hello
> >      I am new to python world . any one can help to guide how we
> > declare variables in python template script and use in if else block
> > and vary it
>
> > for example
> > //need to declare variable here
> > //for example x=0
> > {% for message in message %}
> > //need to put if condition here
> > //ifequal x 0
> > <tr bgcolor="#DDDDDD">
> > //x=1
> > //need to put else condition here
> > <tr bgcolor="#FFFFFF">
> > x=0
> >         <td width='20%'> <a
> > href="/restmessage/mzubair.ahmed?format=xml">mzubair.ahmed </a></td>
>
> >                         <td width='60%'>
> >                                 test
> >                         </td>
> >                         <td width='20%'> 2008-12-12 05:13:45.788901</td>
> >                 </tr>
>
> >  {%endfor%}
>
> No, you can't do that, by design.
>
> But a quick reading of the documentation for the for tag would show
> you how it should be done: use forloop.counter0.
> Seehttp://groups.google.com/group/django-users/browse_thread/thread/3edf...


Or if it's just to alternate between odd and even rows, use the
builtin {% cycle %} tag:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#cycle



--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to