1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #26516 -- Added minlength attribute when forms.CharField.min_length is set.

This commit is contained in:
Jon Dufresne
2016-04-18 17:57:05 -07:00
committed by Tim Graham
parent 836d475afe
commit 500e5a6886
5 changed files with 24 additions and 5 deletions

View File

@@ -235,7 +235,10 @@ class CharField(Field):
attrs = super(CharField, self).widget_attrs(widget)
if self.max_length is not None:
# The HTML attribute is maxlength, not max_length.
attrs.update({'maxlength': str(self.max_length)})
attrs['maxlength'] = str(self.max_length)
if self.min_length is not None:
# The HTML attribute is minlength, not min_length.
attrs['minlength'] = str(self.min_length)
return attrs