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!
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
Challenge Task 2 of 2 Great job! Now we need to add a clean_honeypot method to our class. It should only take self as an argument. You can get the value in honeypot from self.cleaned_data (which acts like a dict). You should raise forms.ValidationError if honeypot has a length. Otherwise, just return honeypot. Your error message can be anything you want.
from django import forms class LeadShareForm(forms.Form): email = forms.EmailField() link = forms.URLField() honeypot = forms.CharField(required=False,widget=forms.HiddenInput) def clean_honeypot(self): honey = self.cleaned_data['honeypot'] if len(honey): raise forms.ValidationError('Bad robot!') return honey
Steven Parker228,096 Points
The code is good except that the indentation is not consistent. Fix the indentation and you'll pass.
Specifically, "def" should begin in the same column as the line above it.