Ticket #7833: 7833-take-2.diff

File 7833-take-2.diff, 1000 bytes (added by Michael Radziej, 16 years ago)
  • django/contrib/auth/forms.py

    a b class UserCreationForm(forms.ModelForm):  
    2828        raise forms.ValidationError(_("A user with that username already exists."))
    2929   
    3030    def clean_password2(self):
    31         password1 = self.cleaned_data["password1"]
     31        password1 = self.cleaned_data.get("password1")
    3232        password2 = self.cleaned_data["password2"]
    3333        if password1 != password2:
    3434            raise forms.ValidationError(_("The two password fields didn't match."))
  • django/contrib/auth/tests/forms.py

    a b False  
    4444>>> form["password2"].errors
    4545[u"The two password fields didn't match."]
    4646
     47The first password isn't specified
     48
     49>>> data = {
     50...     'username': 'jsmith2',
     51...     'password2': 'test123',
     52... }
     53>>> form = UserCreationForm(data)
     54>>> form.is_valid()
     55False
     56>>> form["password1"].errors
     57[u'This field is required.']
     58
    4759The success case.
    4860
    4961>>> data = {
Back to Top