1
0
mirror of https://github.com/django/django.git synced 2025-10-25 06:36:07 +00:00

Fixed #15912 -- Ensured that forms.CharField.widget_attrs() always returns a dictionary. Thanks to tsabi and rubyruy for the report and to mmcnickle and prestontimmons for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17096 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Julien Phalip
2011-11-15 09:36:08 +00:00
parent fae75a32ee
commit a6ccc8cc06
2 changed files with 20 additions and 1 deletions

View File

@@ -197,9 +197,11 @@ class CharField(Field):
return smart_unicode(value)
def widget_attrs(self, widget):
attrs = super(CharField, self).widget_attrs(widget)
if self.max_length is not None and isinstance(widget, (TextInput, PasswordInput)):
# The HTML attribute is maxlength, not max_length.
return {'maxlength': str(self.max_length)}
attrs.update({'maxlength': str(self.max_length)})
return attrs
class IntegerField(Field):
default_error_messages = {