diff options
| author | Alasdair Nicol <alasdair@thenicols.net> | 2015-05-19 10:43:06 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-05-19 08:06:39 -0400 |
| commit | d091b75eefcd02872f7d45e9f5f5dd2fa719bbff (patch) | |
| tree | 1988f9083c7e3abfa5357b0c493e82ac875a76cb /django | |
| parent | ae1efb853c159ae4747d105405694245f8508b4b (diff) | |
Fixed #24818 -- Prevented models.CharField from accepting a string as max_length
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/fields/__init__.py | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index f9ae55f844..3351b4ad35 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -1069,11 +1069,7 @@ class CharField(Field): return errors def _check_max_length_attribute(self, **kwargs): - try: - max_length = int(self.max_length) - if max_length <= 0: - raise ValueError() - except TypeError: + if self.max_length is None: return [ checks.Error( "CharFields must define a 'max_length' attribute.", @@ -1082,7 +1078,7 @@ class CharField(Field): id='fields.E120', ) ] - except ValueError: + elif not isinstance(self.max_length, six.integer_types) or self.max_length <= 0: return [ checks.Error( "'max_length' must be a positive integer.", |
