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 Django Forms Forms Create a Validator

Sameer Zahid
Sameer Zahid
5,967 Points

Stuck at Create a Validator Challenge

Hello,

I'm stuck at the challenge of creating a custom Validator and don't understand why my code isn't getting accepted. So far I've tried this:

def not_treehouse(email):
    email = email.lower()
    if '@teamtreehouse.com' in email:
        raise ValidationError("Email address is from a coworker")

And this:

def not_treehouse(email):
    email = email.lower()
    if email.endswith('@teamtreehouse.com' ):
        raise ValidationError("Email address is from a coworker")

But when I submit I always get this error:

Bummer! Make sure the validator does not allow @teamtreehouse.com email addresses, regardless of capitalization.; Make sure the validator does not allow @teamtreehouse.com email addresses.

Please let me know what's wrong.

Thanks!

1 Answer

Sameer Zahid
Sameer Zahid
5,967 Points

Sorry, silly mistake! Forgot use forms.ValidationError instead of just ValidationError. That fixed it.