Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.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
Django AppEngine:从静态目录加载模板(不仅仅是';/&';)_Django_Google App Engine_Templates - Fatal编程技术网

Django AppEngine:从静态目录加载模板(不仅仅是';/&';)

Django AppEngine:从静态目录加载模板(不仅仅是';/&';),django,google-app-engine,templates,Django,Google App Engine,Templates,我正在尝试使template.render()(导入是:来自google.appengine.ext.webapp导入模板)使用位于应用程序根目录以外的目录中的模板 我有一个名为static的目录,我想在那里保存我的模板。或者,稍后我可能会将其更改为static/templates,但这并不重要 问题出在哪里TemplateDoesNotExist:index.html,一个令人遗憾的例外 这: 。。有效,但这: path = os.path.join(os.path.dirname(__fil

我正在尝试使
template.render()
(导入是:
来自google.appengine.ext.webapp导入模板
)使用位于应用程序根目录以外的目录中的模板

我有一个名为
static
的目录,我想在那里保存我的模板。或者,稍后我可能会将其更改为
static/templates
,但这并不重要

问题出在哪里
TemplateDoesNotExist:index.html
,一个令人遗憾的例外

这:

。。有效,但这:

path = os.path.join(os.path.dirname(__file__), 'static/index.html')
logging.debug(path)
self.response.out.write(template.render(path, template_values))
。。没有

/static
已添加到
app.yaml
,但这并不重要


感谢您的建议。

/static
添加到
应用程序中。yaml
确实会导致
/static
中的文件受到不同的处理

请参见并注意:

如果有需要由应用程序代码读取的数据文件,则数据文件必须是应用程序文件,并且不能与静态文件模式匹配

模板是数据文件

path = os.path.join(os.path.dirname(__file__), 'static/index.html')
logging.debug(path)
self.response.out.write(template.render(path, template_values))