Hi i have an appengine application with the following db.Model:
您好,我有一个appengine应用程序,它具有以下db.Model:
class Cinema(db.Model):
name = db.StringProperty()
address = db.StringProperty()
distance = db.IntegerProperty()
user = db.ReferenceProperty(RunningUser)
When I fill my template everythings works fine:
当我填满模板时,一切都很顺利:
{% for cinema in cinemas %}
<tr>
<td><img src="/images/cinema.png"></td>
<td>
<a href="...">
<h2>{{cinema.name}}</h2>
</a>
{{cinema.address}}
</td>
<td>
{% if cinema.distance > 10000 %}
<p>red</p>
{% endif %}
</td>
</tr>
{% endfor %}
Except the if statement. Python raises a TemplateSyntaxError: 'if' statement improperly formatted exception
. According to Django it should be fine. So what is wrong with these three lines?
除了if语句。Python会引发一个TemplateSyntaxError: 'if'语句格式不正确的异常。根据Django的说法,应该没问题。这三行有什么问题呢?
{% if cinema.distance > 10000 %}
<p>red</p>
{% endif %}
1 个解决方案
#1
1
try this:
试试这个:
{% if cinema.distance > 10000 %}
<p>red</p>
{% endif %}
from: https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#id3
来自:https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs # id3
#1
1
try this:
试试这个:
{% if cinema.distance > 10000 %}
<p>red</p>
{% endif %}
from: https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#id3
来自:https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs # id3