Python Flask Basics Character Builder Starting the Builder

Script Code
Script Code
6,631 Points

jinja2.exceptions.UndefinedError: 'saves' is undefined

app.py

@app.route('/')
def index():
    data = {'user_name': 'JohnDoe'}
    return render_template("index.html", saves=data)

*index.html*
<input placeholder="Type in Your name" type = "text" id= "name" name = "user_name" value = "{{saves.get('user_name', '') }}" autofocus>

JohnDoe gets displayed perfectly in the name input field. However I do get an error: jinja2.exceptions.UndefinedError: 'saves' is undefined.

Why is that?

4 Answers

Script Code
Script Code
6,631 Points

Hi Andreas, a bit of a late response. I do get the errors. Maybe it's worth mentioning that I am using PyCharm.

Alx Ki
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alx Ki
Python Web Development Techdegree Graduate 14,810 Points

I tried your code in PyCharm - it has no errors. If you use PyCharm you should install Flask in the virtualenv of project folder. If you have Flask installed in project's virtualenv - send whole code here to check. else: Kenneth shows how to do it

Same error message for me