:
email_mobile = forms.CharField(widget=forms.TextInput, label="Email or Mobile")
password = forms.CharField(widget=forms.PasswordInput,
label="Password", min_length=6, max_length=50,
error_messages={'min_length': 'Password should be at least 6 characters
long.'})
remember_me = forms.BooleanField(widget=forms.CheckboxInput, required = False)
def clean(self):
cleaned_data = super(AuthenticationForm, self).clean()
try:
if 'email_mobile' in self.cleaned_data:
int(self.cleaned_data['email_mobile'])
if len(self.cleaned_data['email_mobile']) != 10:
raise forms.ValidationError("Please provide a valid 10 digit mobile number.")
except (ValueError, TypeError):
if 'email_mobile' in self.cleaned_data:
validate_email(self.cleaned_data['email_mobile'])
return self.cleaned_data
Am I doing something wrong or is it a bug ?