Hi guys. What is wrong with my codes below? class EmailChangeForm(forms.ModelForm): new_email1 = forms.CharField(label = _("Type new Email")) new_email2 = forms.CharField(label = _("Type Email again"))
def __init__(self, user, *args, **kwargs): self.user = user def clean_new_email2(self): email1 = self.cleaned_data.get('new_email1') email2 = self.cleaned_data.get('new_email2') if email1 and email2: if email1 != email2: raise forms.ValidationError( self.error_messages['password_mismatch']) return email2 def save(self, commit=True): user = super(EmailChangeForm, self).save(commit=False) user.email = self.cleaned_data["email1"] if commit: user.save() return user -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.