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))