python - 谷歌应用引擎 : upload throws "TemplateDoesNotExist: index.html" error

标签 python django google-app-engine

我已经使用 python 和 google app engine 制作了一个应用程序,该应用程序到目前为止在本地主机上运行正常,但是当我使用 google app engine 启动器部署它时,我得到以下信息:

    Traceback (most recent call last):
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py", line 701, in __call__
    handler.get(*groups)
  File "/base/data/home/apps/s~legacyexample01/1.357212630820400434/legacyexample.py", line 78, in get
    self.response.out.write(template.render(path, template_values))
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/template.py", line 91, in render
    t = _load_user_django(template_path, debug)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/template.py", line 113, in _load_user_django
    template = django.template.loader.get_template(file_name)
  File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/loader.py", line 79, in get_template
    source, origin = find_template_source(template_name)
  File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/loader.py", line 72, in find_template_source
    raise TemplateDoesNotExist, name
TemplateDoesNotExist: index.html

我渲染页面的代码如下:

class MainPage(webapp.RequestHandler):
    def get(self):

        template_values = {}

        path = os.path.join(os.path.dirname(__file__), "files/page/index.html")
        self.response.out.write(template.render(path, template_values))

class RegisterPage(webapp.RequestHandler):
    def get(self):

        currentYear = datetime.datetime.now().year
        firstYear = currentYear-100
        template_values = {
            "currentYear" : currentYear,
            "firstYear" : firstYear,
        }

        path = os.path.join(os.path.dirname(__file__), "files/page/register.html")
        self.response.out.write(template.render(path, template_values))

application = webapp.WSGIApplication( [('/', MainPage),('/registration', RegisterPage),('/sign',RegistrationProccess) ], debug=True)

我使用 django 1.3 和 python 2.7 是问题的原因吗?请帮忙

更新 这也是我的 yaml 配置

application: legacyexample01
version: 1
runtime: python
api_version: 1

handlers:
- url: /files/image
  static_dir: files/image

- url: /files/css
  static_dir: files/css

- url: /files/javascript
  static_dir: files/javascript

- url: /files/page
  static_dir: files/page

- url: /.*
  script: legacyexample.py

最佳答案

files/page 中的 index.html 模板是什么?

编辑:

删除

- url: /files/page
  static_dir: files/page

来自 yaml 文件的声明。
您需要可从 .py 文件而不是静态文件访问的 html 模板文件。

关于python - 谷歌应用引擎 : upload throws "TemplateDoesNotExist: index.html" error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9540144/

相关文章:

python - 我如何告诉 [G]vim 去哪里寻找 python26.dll?

python - 如何使 PyMe(Python 库)在 Windows 上的 Python 2.4 中运行?

python - Django , python : reload function in shell

java - 使用 JDO 在 Google 数据存储区中创建实体时出错

java - 如何使用 Google appengine 项目在 Eclipse 中引用另一个项目?

python - Flask 静态文件 Cache-Control

python - 使用 conda 安装和查找共享库

django - 是否可以为某些测试禁用 django haystack?

python - 如何对模型中的 2 个 DecimalFields 求和并显示在管理 View 中?

python - GAE : use static HTML file vs database to serve contents