Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Flask with SQLAlchemy Basics Creating a Basic Website with Flask Forms

jmac pd
jmac pd
11,458 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
.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.