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 trialAdrian Brown
Python Development Techdegree Graduate 14,496 PointsIssue with code.
class RegisterForm(Form):
username = StringField(
'Username',
validators=[
DataRequired(),
Regexp(r'^[a-zA-Z0-9_]+$'),
message=("Username shourld be one word, letters, numbers, and underscores only."),
name_exist
]
)
email = StringField(
'Email',
validators=[
DataRequired(),
Email(),
email_exist()
]
)
password = PasswordField(
'Password',
validators=[
DataRequired(),
Length(min=5),
EqualTo('password2', message='Passwords must match')
]
)
password2 = PasswordField(
'Confirm Password',
validators=[DataRequired()]
)
I get this error message:
(env) abpyguru@Adrians-MBP social-network % python3 app.py
Traceback (most recent call last):
File "/Users/abpyguru/Desktop/Techdegree/five_unit/social-network/app.py", line 4, in <module>
import forms
File "/Users/abpyguru/Desktop/Techdegree/five_unit/social-network/forms.py", line 23
validators=[
^
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
[MOD: added ``` formatting -cf]
2 Answers
Chris Freeman
Treehouse Moderator 68,441 PointsThe line numbers don't match since this is not the whole code.
Could it be that it should be name_exists
(with and "s") and not name_exist
?
Peter Vann
36,427 PointsI agree with Chris. The line:
name_exist
is suspect. My guess/assumption (without testing it) is that it should have the 's' (name_exists) and shouldn't it also be a method/function just like email_exists()? Like this:
name_exists()
I hope that helps. Happy coding!