Ticket #7833: usercreationform.patch
File usercreationform.patch, 1.5 KB (added by , 16 years ago) |
---|
-
django/contrib/auth/tests/forms.py
44 44 >>> form["password2"].errors 45 45 [u"The two password fields didn't match."] 46 46 47 The first password isn't specified 48 49 >>> data = { 50 ... 'username': 'jsmith2', 51 ... 'password2': 'test123', 52 ... } 53 >>> form = UserCreationForm(data) 54 >>> form.is_valid() 55 False 56 >>> form["password1"].errors 57 [u'This field is required.'] 58 47 59 The success case. 48 60 49 61 >>> data = { -
django/contrib/auth/forms.py
29 29 raise forms.ValidationError(_("A user with that username already exists.")) 30 30 31 31 def clean_password2(self): 32 password1 = self.cleaned_data["password1"]33 32 password2 = self.cleaned_data["password2"] 33 34 try: 35 password1 = self.cleaned_data["password1"] 36 except KeyError: 37 # No password has been given to check against. We will 38 # skip our checks since the form will signal this to the 39 # user because the field is required. 40 return password2 41 34 42 if password1 != password2: 35 43 raise forms.ValidationError(_("The two password fields didn't match.")) 36 44 return password2