在 Django Include Tag 中使用函数?

Use function in Django Include Tag?

我正在尝试通过包含选项卡将值传递到模板中,如下所示:

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

所以基本上,我希望 text 值是使用 job.date(上下文对象值)和 [=14= 调用 local_time_format(过滤函数)的结果] 属性 和最后一个参数。

出现 Could not parse the remainder 错误——如何解决?

您可以像这样为包含准备值:

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