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
Łukasz Mikołajczak2,654 Points
Multiple forms in a single route/page with WTForms
I'm trying to complete course "Build a Social Network with Flask" by Kenneth Love and I'm wonder how to identify which form is submitted when I have 2 (or more) in a single page/route.
For example: in course we build register form and login form in 2 different routes /register and /login. What if I want to have both forms in a single route/view?
Thanks in advance!
Kenneth LoveTreehouse Guest Teacher
Hmm. That's a good question and one I'm not 100% certain of the answer to. My first instinct would be name the forms (
< form name="login">) and see if that changes the keys that come in. I doubt it will, though.
If that fails like I suspect it will, you could put the name of the form into the field names. So instead of
name="username" you'd have something like
Neither of these is particularly elegant, though.