Flask modules view can't render templates from app
- From:
- Alex
- Date:
- 2011-02-20 @ 10:58
Hello,
I've tried flask modules structure like this:
/yourapplication
__init__.py
/apps
__init__.py
/frontend
__init__.py
views.py
/static
style.css
/templates
index.html
about.html
...
/admin
__init__.py
views.py
/static
style.css
/templates
list_items.html
show_item.html
And almost everything works fine beside rendering templates.
I do:
@admin.route('/products')
def products():
return render_template('admin/products.html')
and it still points to
/yourapplication/templates/admin/products.html
instead of:
/yourapplication/apps/admin/templates/products.html
Flask documentation (11.1.3 Modules and Resources) says:
"If you want to refer to the templates you just have to prefix it with the
name of the
module. So for the admin it would be
render_template(’admin/list_items.html’)
and so on. It is not possible to refer to templates without the prefixed
module name.
This is explicit unlike URL rules."
But it doesn't seem to work.... What am I doing wrong?
Thanks.