jinja2 template file not found
Hi. I am having trouble getting PyCharm to `find` my jinja2 templates. This causes a lot of unnecessary warnings in my source code; and they're driving me crazy :D
To produce my problem I create a new `Flask` project in pycharm.
Which creates this directory structure:
root
static <dir>
templates <dir>
test.py
Next, I add a simple template `index.html` to the templates directory.
Then I modify the test.py script:
Finally, I mark the templates directory as a template directory. However, the render_template(...) line issues this warning:
Template file 'index.html' not found
Any idea what I'm doing wrong?
Thanks!
jaime
To produce my problem I create a new `Flask` project in pycharm.
Which creates this directory structure:
root
static <dir>
templates <dir>
test.py
Next, I add a simple template `index.html` to the templates directory.
Then I modify the test.py script:
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def hello_world():
return render_template('/index.html')
Finally, I mark the templates directory as a template directory. However, the render_template(...) line issues this warning:
Template file 'index.html' not found
Any idea what I'm doing wrong?
Thanks!
jaime
Please sign in to leave a comment.