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.
Ł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.