Python 如何将静态目录中的文件包含到Django模板继承中
我在django应用程序中有以下目录Python 如何将静态目录中的文件包含到Django模板继承中,python,django,templates,Python,Django,Templates,我在django应用程序中有以下目录 . |-- migrations |-- static | |-- help_content.html | |-- images | `-- vendors `-- templates `-- coolapp |-- other_content.html `-- parent.html 现在在parent.html中,我希望能够做到这一点: {% include "../static/help_conte
.
|-- migrations
|-- static
| |-- help_content.html
| |-- images
| `-- vendors
`-- templates
`-- coolapp
|-- other_content.html
`-- parent.html
现在在parent.html
中,我希望能够做到这一点:
{% include "../static/help_content.html" %}
但它失败了。正确的方法是什么
不过这没关系:
{% include "coolap/other_content.html" %}
include标记将在“TEMPLATES\u DIR”设置中查找指定的文件。当然,静态文件夹不包括在内,也不应该包括(可能,但不太连贯) 我认为你应该把“help_content.html”移到“templates”文件夹中,如果你想在“templates”文件夹中保持秩序,你可以把它放在另一个文件夹中 静态文件夹用于存储.css、.js等文件,例如可以使用“Static”模板标记包含这些文件 希望这对你有帮助