I tried launching my Google App Engine app on local开发者_StackOverflow社区host, and got a Django error I am stuck on.
"TemplateSyntaxError: Template 'base/_base.html' cannot be extended, because it doesn't exist"
I put the templates in a /templates, and then _base.html & index.html in /templates/base . Thanks! Emile @ proudn00b.com
The Error:
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
Referring to :
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)
Another thing you can double check is to make sure one of the paths in the TEMPLATE_DIRS setting points to the root directory for your templates.
Also make sure it's a full absolute path in the setting, not relative to the project.
I think you need to look in your templates. The important part of the traceback is at the end:
Template 'base/_base.html' cannot be extended, because it doesn't exist
Do you have a template named 'base/_base.html'? If not, find what other template file is trying to extend it.
Solution from @jps
rename base/_base.html to just base.html, no subdir. Update index.html with new path.
精彩评论