【发布时间】:2022-01-06 19:41:19
【问题描述】:
所以我有一个base.html 模板和一个扩展base.html 模板的review_result.html 模板。 base.html 模板有一个脚本标签,有很多功能。我将把名为format 的函数从review_result.html 中的脚本标记移动到base.html 文件。然后如何从base.html 调用review_result.html 中的format 函数?
【问题讨论】:
-
你说你的
base.html有一个脚本标签是什么意思?一般来说,模板不包含功能代码或标签。可用的标签要么是内置的,要么是由您的站点配置控制的,或者是使用{% load %}加载的——在任何情况下,它们都不在您的模板内部。见custom template tags。另外,这是否回答了您的问题:Is it possible to load a custom template tag in base and use it in extented templates ? -
你好,欢迎来到 SO。这是一个很好的问题,但您可以编辑您的帖子并添加您尝试过的任何代码吗?它肯定会帮助任何答案。
标签: python html django templates django-templates