1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #22206 -- Passed models.TextField.max_length to forms.CharField.maxlength

This commit is contained in:
Chris Wilson
2014-03-04 14:12:13 +00:00
committed by Claude Paroz
parent ac699cdc17
commit 95c74b9d69
8 changed files with 37 additions and 8 deletions

View File

@@ -223,7 +223,7 @@ class CharField(Field):
def widget_attrs(self, widget):
attrs = super(CharField, self).widget_attrs(widget)
if self.max_length is not None and isinstance(widget, TextInput):
if self.max_length is not None:
# The HTML attribute is maxlength, not max_length.
attrs.update({'maxlength': str(self.max_length)})
return attrs