Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何将静态目录中的文件包含到Django模板继承中_Python_Django_Templates - Fatal编程技术网

Python 如何将静态目录中的文件包含到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

我在django应用程序中有以下目录

.
|-- 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”模板标记包含这些文件

希望这对你有帮助