未找到Google App Engine模板

use*_*854 5 google-app-engine python-2.7

我使用webapp在Python 2.5中为Google App Engine编写了一个轻量级应用程序.

在我将其迁移到Python 2.7之后,我发现了TemplateDoesNotExist错误:TemplateDoesNotExist:../../ base.html

我听说禁止相对导入模板.

  1. 是否足以使模板导入绝对?
  2. 如果是的话,该怎么办?

当我搜索这个问题时,我看到了许多Django文章,但我没有使用它,除了webapp.template.

我的项目结构是这样的(虽然我知道它并不好).

src/
  - template/
    - base.html
    - foo/
      - foo.html      (imports base.html)
      - bar/
        - foobar.html (imports ../foo.html)
        - bar.html    (imports ../../base.html)
 - main.py   (imports the following; app = WSGIApplication(...))
 - foo.py    (defines class Foo    which uses foo.html) 
 - bar.py    (defines class Bar    which uses bar.html)
 - foobar.py (defines class FooBar which uses foobar.html)
Run Code Online (Sandbox Code Playgroud)