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 trialLewis Cowles
74,902 Points:'( My form clean won't work
so I have no clue why this is not working... looks to be the same to me as the example in the video. Kenneth Love ideas?
from django import forms
def not_treehouse(value):
if value.lower().endswith('@teamtreehouse.com'):
raise forms.ValidationError('Just come talk to me')
class LeadShareForm(forms.Form):
email = forms.EmailField(validators=[not_treehouse])
email2 = forms.EmailField(label='Email again', 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
def clean(self):
cleaned = super.clean();
email = cleaned.get('email')
verify = cleaned.get('email2')
if email != verify:
raise forms.ValidationError('Hey!')
1 Answer
Chris Freeman
Treehouse Moderator 68,457 PointsI see two differences: super()
needs parens, and a trailing semi-colon:
def clean(self):
cleaned = super().clean() # <-- add parens, remove semi-colon
email = cleaned.get('email')
verify = cleaned.get('email2')
if email != verify:
raise forms.ValidationError('Hey!')
Lewis Cowles
74,902 PointsLewis Cowles
74,902 PointsI must be blind, thx Chris