【发布时间】:2011-03-31 19:44:50
【问题描述】:
我尝试在 localhost 上启动我的 Google App Engine 应用程序,但遇到了一个 Django 错误,我被卡住了。
“TemplateSyntaxError: Template 'base/_base.html' 无法扩展,因为它不存在”
我将模板放在 /templates 中,然后将 _base.html 和 index.html 放在 /templates/base 中。谢谢! 埃米尔@proudn00b.com
错误:
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/__init__.py", line 511, in __call__
handler.get(*groups)
File "/Users/emilepetrone/code/thebuswheel/main.py", line 65, in get
outstr = template.render(temp, { 'path': path })
….
…..
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django/django/template/loader_tags.py", line 58, in get_parent
raise TemplateSyntaxError, "Template %r cannot be extended, because it doesn't exist" % parent
TemplateSyntaxError: Template 'base/_base.html' cannot be extended, because it doesn't exist
参考:
def get(self):
path = self.request.path
temp = os.path.join(
os.path.dirname(__file__),
'templates' + path)
if not os.path.isfile(temp):
temp = os.path.join(
os.path.dirname(__file__),
'templates/base/index.html')
outstr = template.render(temp, { 'path': path })
self.response.out.write(outstr)
【问题讨论】:
标签: python google-app-engine django-templates