Sunday, 15 July 2012

python - Not able to use conditional tags in for loop in Django template file -


I am using Django 1.4 / Python 2.7.9 (because I need it, I know that 1.4 now Is very old) and I'm very green with the degena / python in my template file, I think that any cold conditional tags such as ifchanged or forequal loop are unable to be used within.

For example:

  {% Examples in allsamples% example {{ifchanged example.brand%} & lt; H2 & gt; {{Example.brand}} & lt; / H2 & gt; {% Endifchanged%} {% endfor%}  

This error throws "unmarked unknown tag 'changed' '. Jinja was searching for the following tag:' Endor 'or' The 'inner' block which needs to be closed is 'for'.

I have tried the effects even there - the same error prevents me from using other tags for a loop is?

If you have Jinja2 solution, you can call it if / else < / Code> and set :

  for example% allsamples%} {% if example.brand! = Last_brand%} & lt; H2 & gt; {{Example.brand}} & lt; / H2 & gt; Set {% Last_brand = asample.brand%} {% endif%} {% endfor%}  

No comments:

Post a Comment