2010-08-18 41 views
1

我試圖在本地主機上啓動我的Google App Engine應用程序,並且遇到了Django錯誤。Google App Engine中的Django模板語法錯誤

「TemplateSyntaxError:模板‘基地/ _base.html’不能擴展,因爲它不存在」

我把模板在/模板,然後_base.html &的index.html在/模板/基地。謝謝! 埃米爾@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 

參考:

高清得到(個體經營):

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) 

回答

0

我認爲你需要在你的模板來看看。回溯的重要組成部分,是在最後:

模板「基地/ _base.html」不能擴展,因爲它不存在

你有一個名爲「基地/ _base.html」模板?如果沒有,找到其他模板文件試圖擴展它。

+0

我確實有base/_base.html文件,這是唯一的模板文件。 Def部分挫折 – Emile 2010-08-18 22:59:33

+0

也許它會幫助顯示你的模板和yaml配置文件。 :-) – jps 2010-08-19 01:14:23

+0

這些文件對於計算器來說太長了,所以我把它們發佈到了博客上... http://www.proudn00b.com/post/976956081/buswheel-files-4-error – Emile 2010-08-19 12:20:20

1

您可以仔細檢查的另一件事是確保TEMPLATE_DIRS設置中的一個路徑指向您的模板的根目錄。

還要確保它是設置中的完整絕對路徑,而不是相對於項目。

0

從@jps解

重命名鹼/ _base.html只是base.html文件,沒有子目錄。用新路徑更新index.html。