механизм приложений Google: загрузка выдает ошибку «TemplateDoesNotExist: index.html» - PullRequest
1 голос
/ 03 марта 2012

Я создал приложение, используя python и google app engine, пока что приложение работает нормально на localhost, но при развертывании его с помощью средства запуска 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

1 Ответ

7 голосов
/ 03 марта 2012

это шаблон index.html в файлах / странице?

edit:

удалить

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

это объявление из файла yaml.
вам нужны файлы шаблонов html, доступные из.Py файлы, а не как статические файлы.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...