简体   繁体   中英

template not found, deploying Pyramid on Webfaction

I'm trying to deploy my webapp to Webfaction, the basic example is working correctly, I got a TemplateNotFound in a template that extends a basic template using Jinja2. Here is my project tree:

/webapps
    /myapp
        development.ini
        production.ini
        /bin
    /theapp
        /Project
          setup.py
          /project
              __init__.py
              views.py
              /templates
                  base.jinja2
                  home.jinja2
              /static

_ init _.py

config.include('pyramid_jinja2')
config.add_jinja2_search_path("templates")

home.jinja2

{% extends "templates/base.jinja2" %}

To be more clear, the project works locally I know it's something with the template path, I'm not sure how to set it, I tried many different ways, anyways this is the traceback:

  File "..webapps/myapp/myapp/Project/project/templates/home.jinja2", line 1, in top-level template code
    {% extends "templates/base.jinja2" %}
  File "..webapps/myapp/lib/python2.7/site-packages/pyramid_jinja2-1.8-py2.7.egg/pyramid_jinja2/__init__.py", line 193, in get_source
    raise TemplateNotFound(name=ex.name, message=message)
TemplateNotFound: templates/base.jinja2; asset=..webapps/myapp/lib/python2.7/site-packages/Project-0.0-py2.7.egg/project/templates/base.jinja2; searchpath=['..webapps/myapp/lib/python2.7/site-packages/Project-0.0-py2.7.egg/project/templates']

Please help me set the correct path to templates, if that is my mistake.

Since the search path is '..webapps/myapp/lib/python2.7/site-packages/Project-0.0-py2.7.egg/project/templates' , that tells me you installed your application as an egg using python setup.py install . By far the most common pitfall of distributing your app in this way is that it requires a MANIFEST.in file when packaging your application in order for it to include static assets. python setup.py develop runs the application out of the directory instead, and does not suffer from that problem. I expect that if you unzip your egg file you will not find your templates inside.

尝试在扩展文件中添加文件MANIFEST.。

recursive-include project *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM