Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

Hi Script Code

I have run your code and don't seem to get any errors !!

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,822 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