1class AccountForm(forms.Form):
2 email = forms.EmailField(max_length=255)
3 username = forms.CharField(max_length=40)
4 password = PasswordField(label="Password")
5 password_confirm = PasswordField(label="Password")
6
7 def clean(self):
8 cd = self.cleaned_data
9 if cd.get('password') != cd.get('password_confirm'):
10 self.add_error('password_confirm', "passwords do not match !")
11 return cd
12
1class AccountForm(forms.Form):
2 ....your stuff
3
4 def clean_password(self):
5 if self.data['password'] != self.data['password_confirm']:
6 raise forms.ValidationError('Passwords are not the same')
7 return self.data['password']
8