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 trialstevencucolo
5,961 PointsDjango Forms: custom validator - not_treehouse
I can't find what is wrong with my code on this chanllenge
from django import forms
from django.core import validators
def not_treehouse(value):
value = value.lower()
if value.endswidth("@teamtreehouse.com"):
raise forms.ValidationError("no treehouse emails!")
class LeadShareForm(forms.Form):
email = forms.EmailField(validators=[not_treehouse],)
link = forms.URLField()
honeypot = forms.CharField(widget=forms.HiddenInput, required=False)
def clean_honeypot(self):
honey = self.cleaned_data['honeypot']
if len(honey):
raise forms.ValidationError('Bad robot!')
return honey
When I submit, it returns an error with the message:
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.
Can someone please point out why the code is not passing? thanks.
1 Answer
stevencucolo
5,961 PointsSo, I just "restarted" the challenge, and re-wrote all the code from scratch, and now what I wrote passes. weird.