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 A Social Network with Flask Takin' Names Macros

David Sampimon
David Sampimon
12,026 Points

AttributeError: 'RegisterForm' object has no attribute 'validate_on_submit'

It seems that the 'validate_on_submit' method is no longer available for flask_wtf.Form, if you try to run the downloadable project you get a:

''' File "C:\python_projects\socialapp\app.py", line 42, in register if form.validate_on_submit(): AttributeError: 'RegisterForm' object has no attribute 'validate_on_submit' '''

after a quick stackoverflow search I swapped out the Form with a flask_wtf.FlaskForm, this runs the script, however then validation seems to be working incorrectly.

This is now becoming a recurring theme with teamtreehouse, that I get stuck on a Python courses due to the course material being out-of-date (the same with 'Flask REST API' course: https://teamtreehouse.com/community/jsonwebsignatureserializer-depricated-from-itsdangerous-use-authlib-instead).

Could you please revisit the course material if it at least still works?

Jeff Muday
Jeff Muday
Treehouse Moderator 28,717 Points

I understand that it is quite frustrating. I would end up redoing some of the videos too, especially this one! (I wish I could, but I am only a moderator.)

There is a definite "shelf-life" that a video has. This was cutting edge in 2017 or so, but the Flask-WTF major version changed in 2021 and 2022 so it no longer reflects what it was in 2017.

The only way to "play along" with the video is to pip install flask-wtf==0.14.3 but that causes other issues as well. Then there's Flask itself. Flask is a couple of versions newer too! So you are getting a real Flask education!

1 Answer

kevin stradtman
kevin stradtman
10,172 Points

You could use and import FlaskForm instead of Form. I found this worked for me!