Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 please help me...

like image 766
Ginni Avatar asked Jan 21 '23 14:01

Ginni


2 Answers

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%}
like image 198
David Underhill Avatar answered Jan 30 '23 20:01

David Underhill


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.

like image 41
Giuseppe Lavagetto Avatar answered Jan 30 '23 19:01

Giuseppe Lavagetto