Re: enumerate in templates

2008-12-29 Thread James Bennett

On Mon, Dec 29, 2008 at 3:02 AM, Vicky  wrote:
> command like below is not working... can u suggest a way??

It is very, very, very, very important to read the big warning at the
top of the template documentation, which states that the Django
template language *is not* just Python code embedded in HTML, and
which explains that only the specific things described in the
documentation will work. A large part of your problem seems to be that
you're ignoring this and simply dumping random Python expressions into
a template, when it's clearly stated that you can't do that (well, you
can, it just won't do anything useful).

You might want to take a step back and go through the template
documentation thoroughly, then think about how you're structuring the
data that's passed into your templates; in the overwhelming majority
of cases, attempts to put this much logic into a template (which is
meant to provide the bare minimum of logical constructs needed to
present data) imply a problem somewhere else in the code.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Re: enumerate in templates

2008-12-29 Thread Vicky

command like below is not working... can u suggest a way??


{% for node in nodes %}
{% ifequal nodes[(forloop.counter0)-1].node_type '2' %}






On Dec 29, 9:21 am, Vicky  wrote:
> ya that's what i need :) thanks a lot :) :)
>
> On Dec 28, 8:06 pm, Daniel Roseman 
> wrote:
>
> > On Dec 27, 6:20 am, Vicky  wrote:
>
> > > Is there a way to access the previous value of a for loop in
> > > templates. Can anyone tell the template representation for the python
> > > code like:
>
> > >                          for i,j in enumerate(item):
> > >                         ...
>
> > I think the various forloop variables are what you want.
>
> > {% for j in item %}
> > {{ forloop.counter0 }}
> > {% endfor %}
>
> > See :http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for
> > --
> > DR.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: enumerate in templates

2008-12-28 Thread Vicky

ya that's what i need :) thanks a lot :) :)

On Dec 28, 8:06 pm, Daniel Roseman 
wrote:
> On Dec 27, 6:20 am, Vicky  wrote:
>
> > Is there a way to access the previous value of a for loop in
> > templates. Can anyone tell the template representation for the python
> > code like:
>
> >                          for i,j in enumerate(item):
> >                         ...
>
> I think the various forloop variables are what you want.
>
> {% for j in item %}
> {{ forloop.counter0 }}
> {% endfor %}
>
> See :http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for
> --
> DR.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: enumerate in templates

2008-12-28 Thread Daniel Roseman

On Dec 27, 6:20 am, Vicky  wrote:
> Is there a way to access the previous value of a for loop in
> templates. Can anyone tell the template representation for the python
> code like:
>
>                          for i,j in enumerate(item):
>                         ...

I think the various forloop variables are what you want.

{% for j in item %}
{{ forloop.counter0 }}
{% endfor %}

See :
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for
--
DR.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: enumerate in templates

2008-12-27 Thread Alex Koshelev
{% for %} itself

On 12/27/08, Vicky  wrote:
>
> Is there a way to access the previous value of a for loop in
> templates. Can anyone tell the template representation for the python
> code like:
>
>  for i,j in enumerate(item):
> ...
> >
>


-- 
---
Александр Кошелев
daeva...@gmail.com

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



enumerate in templates

2008-12-27 Thread Vicky

Is there a way to access the previous value of a for loop in
templates. Can anyone tell the template representation for the python
code like:

 for i,j in enumerate(item):
...
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---