template not found, deploying Pyramid on Webfaction

安稳与你 提交于 2019-12-08 01:06:24

问题


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.


回答1:


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.




回答2:


Try add in file MANIFEST.in the extesion files.

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


来源:https://stackoverflow.com/questions/19174463/template-not-found-deploying-pyramid-on-webfaction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!