Hellow {% e...">

TemplateSyntaxError: if statement incorrectly formatted

{% for frequency in patient_meds.frequency %} {% if frequency == "7" %} <td>Hellow</td> {% endif %} {% endfor%} 

getting an error

TemplateSyntaxError: if statement incorrectly formatted

I do not know what to do, please help me ...

+4
source share
4 answers

If you are using the standard version of Django included in the application engine (v0.96), try this syntax:

 {% for frequency in patient_meds.frequency %} {% ifequal frequency "7" %} <td>Hellow</td> {% endif %} {% endfor%} 
+6
source

To be able to use the == syntax in the {% if %} , you need to use Django 1.2 or higher.

Django 1.2 ships with your GAE SDK, but it loads 0.96 by default.

You can use version 1.2 of django by declaring the version of the third-party library that you want to use with the use_library() function provided by the google.appengine.dist package. Just put this code at the very top of your python file (at least before importing anything from django:

 from google.appengine.dist import use_library use_library('django', '1.2') 

So your template should look good.

+2
source

The syntax should be endifequal :

 {% for frequency in patient_meds.frequency %} {% ifequal frequency "7" %} <td>Hellow</td> {% endifequal %} {% endfor%} 
+1
source

The syntax == in the tag {% if %} is only available from version 1.2 of Django :)

0
source

Source: https://habr.com/ru/post/1338435/


All Articles