Wednesday, June 26, 2013

Re: forloop breaking

The best thing I can think of is to send from the view a set/list of available attributes such that there is at least one item with a non empty value for those attributes. This can be achieved by a single iteration on the iterable `st'. Then in the template, you can just check if, for example Description is there in that attribute list and write the heading for it only then. Hope that helps.


On Wed, Jun 26, 2013 at 9:12 PM, Harjot Mann <harjotmann1992@gmail.com> wrote:
Actually I want to remove the heading of my table in templates if it
is not filled. I have done this using this coding:
{% for test in st|slice:":1" %}<th>S.No</th>
  {% ifnotequal test.Description "" %}   <th>Description</th>{% endifnotequal %}
  {% ifnotequal test.Thickness "" %}    <th>Thickness</th>{% endifnotequal %}
  {% ifnotequal test.Comp_Strength_MPa "" %}    <th>Compressive
Strength(Mpa)</th>{% endifnotequal %}
                {% endfor  %}</tr>

but the problem which I am facing that if I dont enter the value in
first row and add that vale in second row then it does not show the
heading but shows the value.
I want that my headings should appear single time in table but it if
there is some value in second row then it should display its heading.



--
Harjot Kaur Mann
Blog: http://harjotmann.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.





--
Yati Sagade

Software Engineer at mquotient

Twitter: @yati_itay | Github: yati-sagade

Organizing member of TEDx EasternMetropolitanBypass
http://www.ted.com/tedx/events/4933
https://www.facebook.com/pages/TEDx-EasternMetropolitanBypass/337763226244869

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment