使用Django Include Tag中的函数



我正试图通过include选项卡将值传递到模板中,如下所示:

{% include "shared/page_title.html" with text=local_time_format(job.date, user.timezone, "M j P") %}

因此,基本上,我希望text值是用job.date(上下文对象值(和user属性以及最终参数调用local_time_format(过滤函数(的结果。

获取Could not parse the remainder错误--如何修复?

您可以为include准备值,比如:

{% with text=today|date:"D d M Y" %}
{% include "shared/page_title.html" with text=text%}
{% endwith %}

最新更新