Hi. Upon login, user can go to email_change_form.html to update their email address. They will enter their new email twice to update their profile. Actually, a change email confirmation would be perfect.
On Tuesday, May 14, 2013 3:33:41 PM UTC+8, Nathaniel wrote: > > 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.