Django: TemplateSyntaxError: Could not parse the remainder: '|' from 'eligibility_date|'

Django: TemplateSyntaxError: Could not parse the remainder: '|' from 'eligibility_date|'

我在我的一个模板中使用了以下代码。并收到错误 TemplateSyntaxError: Could not parse the remainder: '|' from 'eligibility_date|'. 我已经搜索了很多,但找不到 date 过滤器与 {% with %} {% endwith %} 的任何用法。 `

{% with eligibility_date=eligibility_date|date: "m/d/Y" %}
    {% blocktrans %} {{eligibility_date}} {% endblocktrans %}
{% endwith %}

date"m/d/Y"之间不应该有space:

{% with eligibility_date=eligibility_date|date:"m/d/Y" %}