Re: Template - counter for if loop

2011-06-02 Thread Tim Shaffer
I think you might want the heading outside the loop:

My Heading 
{% for val in data %} 
 {% ifnotequal val 2 %} 
 {{val}}  
 {% endifnotequal  %} 
{% endfor %} 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/N2w4UTFHTUxSSjBK.
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.



Template - counter for if loop

2011-06-02 Thread jai_python
I need to show the heading only one time when forloop executed along
with if-loop;
example:
-
data.html
--

{% for val in data %}
 {% ifnotequal val 2 %}
 My Heading
 {{val}} 
 {% endifnotequal  %}
{% endfor %}

Input

data=[1,2,3,4,5,2,6]

Excepted Out put:
---

My heading
1
3
4
5
6

Here "My Heading" shouldn't repeat and it should occur one time. We
can't use forloop.counter/first, since we have a if-loop condition .

Pl let me know how to implement it.

Thanks & Regards,
Jai

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