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 with SQLAlchemy Basics Creating a Basic Website with Flask Forms

jmac pd
jmac pd
11,490 Points

Flask Basics - Forms - KeyError: 'name'

for anyone wondering why they are getting a 'wekzeug.exceptions.badrequestkeyerror' in the demonstration, the teach uses the print function to call the form['name'] inside the add_pet() function.

this is done when the page is already loaded, and there is a form['name'] to access. If you reload your page, you will get an error.

This was likely done as a demonstration on how you could access the data, not anything you would do in the real world.

You will need to comment out the print to load the page again

1 Answer

Megan Amendola
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Megan Amendola
Treehouse Teacher

Great clarification! You're exactly right! It's a great way to play around and see what's happening but you wouldn't want those print statements in there with a live website.