开发者

TemplateSyntaxError: 'if' statement improperly formatted

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

getting error

TemplateSyntaxError: 'if' statement improperly formatted

i don't know what i have to do pleas开发者_如何转开发e help me...


If you're using the default version of Django included with app engine (v0.96), then try this syntax:

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


In order to be able to use the == syntax in the {% if %} statement, you need to use Django 1.2 or above.

Django 1.2 comes with your GAE SDK, but 0.96 is loaded by default.

You can use version 1.2 of django , by declaring the version of the third-party library 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')

This way, your template should render nicely.


The syntax should be endifequal:

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜