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 trialTafadzwa Timothy Gakaka
10,978 Pointsim lost
help
from flask_wtf import Form
from wtforms import StringField, PasswordField
from wtforms.validators import (DataRequired, Regexp, ValidationError, Email,
Length, EqualTo)
def email_exists(form, field):
if User.select.where(User.email == field.data).exists():
raise ValidationError('User with that email already exists.')
def name_exists(form, field):
if User.select.where(User.username == field.data).exists():
raise ValidationError('User with that name already exists.')
class SignUpForm(Form):
email = StringField(
'Email',
validators=[
DataRequired(),
Email(),
email_exists
])
password = PasswordField(
'Password',
validators=[
DataRequired(),
Length(min=2),
EqualTo('password2', message='Password must match')
])
1 Answer
Mel Rumsey
Treehouse ModeratorHey Tafadzwa Timothy Gakaka So you said in your other post that you are stuck on the 3rd challenge which is asking: Add DataRequired and Email to the validators for the email field.
I am not sure where all of your other code is coming from because none of the challenges before it asked for Validators in the password field, or either of those functions. Keep it simple. The 2nd challenge asked for the SignUpForm class with email equaling a string field and the password equaling a password field. But nothing else was required therefor all of your extra code is causing the challenge to error out.