无法解析余数:来自“%”Django 的“%”
Could not parse the remainder: '%' from '%' Django
我正在与 Django
Mezannine
合作,我 运行 遇到了一个奇怪的 jinja 问题。
TemplateSyntaxError at /services/
Could not parse the remainder: '%' from '%'
Request Method: GET
Request URL: http://192.168.1.14/services/
Django Version: 1.8.3
Exception Type: TemplateSyntaxError
Exception Value:
Could not parse the remainder: '%' from '%'
Exception Location: /usr/local/lib/python3.4/dist-packages/django/template/base.py in __init__, line 639
Python Executable: /usr/bin/python3
Python Version: 3.4.3
我的代码如下所示:
{% for image in images %}
{% if loop.index % 3 == 0 %} #this is the line it doesn't like
{{image}}
{% endif %}
{% endfor %}
知道这里发生了什么吗?
谢谢
% 由 Django 保留,所以你必须使用 divisibleby
{% for image in images %}
{% if forloop.counter|divisibleby:"3" %}
{{image}}
{% endif %}
{% endfor %}
我正在与 Django
Mezannine
合作,我 运行 遇到了一个奇怪的 jinja 问题。
TemplateSyntaxError at /services/
Could not parse the remainder: '%' from '%'
Request Method: GET
Request URL: http://192.168.1.14/services/
Django Version: 1.8.3
Exception Type: TemplateSyntaxError
Exception Value:
Could not parse the remainder: '%' from '%'
Exception Location: /usr/local/lib/python3.4/dist-packages/django/template/base.py in __init__, line 639
Python Executable: /usr/bin/python3
Python Version: 3.4.3
我的代码如下所示:
{% for image in images %}
{% if loop.index % 3 == 0 %} #this is the line it doesn't like
{{image}}
{% endif %}
{% endfor %}
知道这里发生了什么吗?
谢谢
% 由 Django 保留,所以你必须使用 divisibleby
{% for image in images %}
{% if forloop.counter|divisibleby:"3" %}
{{image}}
{% endif %}
{% endfor %}