diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2006-12-15 23:07:41 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2006-12-15 23:07:41 +0000 |
| commit | 26489d4e2aa2a5d06b228643dfc232c05bb47872 (patch) | |
| tree | 44ffa04d0937bf581d85d6710dfd12cc0a2d4f4f /django/newforms | |
| parent | 4f5170bffe8ca6ce8da0f68c4834066b0c766b43 (diff) | |
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
Diffstat (limited to 'django/newforms')
| -rw-r--r-- | django/newforms/fields.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/django/newforms/fields.py b/django/newforms/fields.py index 24849bdbcf..af2533cec5 100644 --- a/django/newforms/fields.py +++ b/django/newforms/fields.py @@ -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) |
