I’m trying to make template.render() (import was: from google.appengine.ext.webapp import template) use a template located in a directory other than the root of the application.
I have a directory, called static, where I’d like to keep my templates. Or possibly, I’ll change that to static/templates later, but this doesn’t matter.
The problem? TemplateDoesNotExist: index.html, a sad exception.
This:
path = os.path.join(os.path.dirname(__file__), 'index.html')
logging.debug(path)
self.response.out.write(template.render(path, template_values))
.. works, but this:
path = os.path.join(os.path.dirname(__file__), 'static/index.html')
logging.debug(path)
self.response.out.write(template.render(path, template_values))
.. does not.
/static has been added to app.yaml, although it shouldn’t matter.
Thanks for any advice.
Adding
/statictoapp.yamldoes cause files in/staticto be treated differently.See http://code.google.com/appengine/docs/python/config/appconfig.html#Static_File_Handlers and note:
Templates are data files.