Django TemplateSyntaxError: Could not parse the remainder: '"{%' from '"{%'
Django TemplateSyntaxError: Could not parse the remainder: '"{%' from '"{%'
我正在尝试在 for 循环中执行循环,但它引发了错误。正确的选择是什么。
{% cycle "{% include 'col-1-of-3.html' %}" "{% include 'col-2-of-3.html' %}" "{% include 'col-3-of-3.html' %}" %}
错误:
TemplateSyntaxError: Could not parse the remainder: '"{%' from '"{%'
只需使用要包含在 {% cycle … %}
template tag [Django-doc], and assign it to a variable (tmp
for example). Then you can use that variable in the {% include … %}
template tag [Django-doc]:
中的文件名
{% for variable in loop %}
{% cycle 'col-1-of-3.html' 'col-2-of-3.html' 'col-3-of-3.html' <b>as tmp silent</b> %}
{% include <b>tmp</b> %}
{% endfor %}
我正在尝试在 for 循环中执行循环,但它引发了错误。正确的选择是什么。
{% cycle "{% include 'col-1-of-3.html' %}" "{% include 'col-2-of-3.html' %}" "{% include 'col-3-of-3.html' %}" %}
错误:
TemplateSyntaxError: Could not parse the remainder: '"{%' from '"{%'
只需使用要包含在 {% cycle … %}
template tag [Django-doc], and assign it to a variable (tmp
for example). Then you can use that variable in the {% include … %}
template tag [Django-doc]:
{% for variable in loop %}
{% cycle 'col-1-of-3.html' 'col-2-of-3.html' 'col-3-of-3.html' <b>as tmp silent</b> %}
{% include <b>tmp</b> %}
{% endfor %}