Custom Validation
clean_<field> checks one field.
Example
class SignUp(forms.Form):
username = forms.CharField()
def clean_username(self):
u = self.cleaned_data["username"]
if " " in u:
raise forms.ValidationError("No spaces")
return uExercise
Raise an error.
raise forms.Error("x")
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.