2011-06-29 22 views
1

我試圖使template.render()(導入爲:from google.appengine.ext.webapp import template)使用位於應用程序根目錄以外的目錄中的模板。AppEngine:從靜態目錄加載模板(不只是'/')

我有一個目錄,名爲static,我想保留我的模板。或者,稍後我會將其更改爲static/templates,但這並不重要。

問題? TemplateDoesNotExist: index.html,一個悲傷的例外。

此:

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

..工作,但這樣的:

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,但它應該沒有關係。

感謝您的任何建議。

回答