我尝试在localhost上启动Google App Engine应用程序,但遇到了Django错误。
“ TemplateSyntaxError:模板'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():
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)
最佳答案
我认为您需要查看模板。回溯的重要部分在最后:
模板“ base / _base.html”无法扩展,因为它不存在
您是否有一个名为“ base / _base.html”的模板?如果不是,请查找其他模板文件试图对其进行扩展。