Hi,

I am using django 1.8.7. I noticed that max_length for form is not working. 
The form validates even when the max_length is set and password length is 
more than 50 for following code. Though the min_length works fine.


class AuthenticationForm(forms.Form)
:
    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 ?

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/12a685d0-d85d-4b76-929b-bc15c5cd847e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to