python - HTML templating using Jinja2 No module named your app -
i trying create html template in python using jinja2. have templates folder 'template.html' don't know how deal environments or package loaders.
i installed jinja2. these simple codes
from jinja2 import environment, packageloader env = environment(loader=packageloader('ap', 'templates')) template = env.get_template('template.html') print template.render(title='hello')
i error:
file "a.py", line 3, in <module> env = environment(loader=packageloader('ap', 'templates')) file "/usr/local/lib/python2.7/dist-packages/jinja2-2.7-py2.7.egg/jinja2/loaders.py", line 214, in __init__ provider = get_provider(package_name) file "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 213, in get_provider __import__(moduleorreq) importerror: no module named ap
this folders
ap/ __init__.py a.py templates/ template.html
where wrong ? why error "no module named application"
i don't know environments , loaders, use:
jinja_environment = jinja2.environment( loader=jinja2.filesystemloader('%s/templates/' % os.path.dirname(__file__)) )
Comments
Post a Comment