【问题标题】:Could not parse the remainder: '(5+6)' from '(5+6)'无法解析余数:来自“(5+6)”的“(5+6)”
【发布时间】:2021-08-09 11:54:37
【问题描述】:

我在玩 jinja 模板,突然发现 DateTime 字段比较有一些错误。然后尝试像这样简单的数字比较:

{% if (5+6) > 1 %}
   <p> This will display if the condition is true </p>
{% endif %}

但它说错误(对于这个 if 条件):

TemplateSyntaxError at /examevent/
Could not parse the remainder: '(5+6)' from '(5+6)'

为什么会发生,如何解决?

【问题讨论】:

    标签: python django jinja2


    【解决方案1】:

    试试这个:%}->-%}{%->{%-

    {% if (5+6) > 1 -%}
       <p> This will display if the condition is true </p>
    {%- endif %}
    

    【讨论】:

      猜你喜欢
      • 2016-09-10
      • 2016-04-26
      • 2015-12-11
      • 2019-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多