on page 168, there 2 pieces of code :
def clean_password2(self): if self.cleaned_data['password1'] != self.cleaned_data['password2']: raise forms.validationerror("you must type same password each time") return self.cleaned_data['password2'] def clean(self): if 'password1' in self.cleaned_data , 'password2' in self.cleaned_data: if self.cleaned_data['password1'] != self.cleaned_data['password2']: raise forms.validationerror("you must type same password each time") return self.cleaned_data
in second case, code checks whether 'password1' , 'password2' have value. in first case, there no such check. why ?
in clean_password2
validating password2
field exists on form , don't need check existence of in self.cleaned_data
. doesn't mean couldn't check eixstence of password1
, however.
the clean
method validating whole form , has no guarantees of present.
Comments
Post a Comment