我使用python和谷歌应用程序引擎制作了一个应用程序,该应用程序到目前为止在localhost上工作正常但是当我使用谷歌应用程序引擎启动器部署它时,我得到以下内容:
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
答案 0 :(得分:7)
是files / page中的index.html模板吗?
编辑
删除
- url: /files/page
static_dir: files/page
来自yaml文件的声明。
您需要可从.py文件访问的html模板文件,而不是静态文件。