mirror of
https://github.com/django/django.git
synced 2025-10-25 06:36:07 +00:00
newforms: Fixed unexpected behavior with CharField(required=False, min_length=X). Thanks for reporting, Benjamin Slavin
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4217 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -77,7 +77,10 @@ class CharField(Field):
|
||||
def clean(self, value):
|
||||
"Validates max_length and min_length. Returns a Unicode object."
|
||||
Field.clean(self, value)
|
||||
if value in EMPTY_VALUES: value = u''
|
||||
if value in EMPTY_VALUES:
|
||||
value = u''
|
||||
if not self.required:
|
||||
return value
|
||||
value = smart_unicode(value)
|
||||
if self.max_length is not None and len(value) > self.max_length:
|
||||
raise ValidationError(gettext(u'Ensure this value has at most %d characters.') % self.max_length)
|
||||
|
||||
Reference in New Issue
Block a user