diff options
| author | MattBlack85 <promat85@gmail.com> | 2014-11-18 15:03:13 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-11-26 18:41:54 -0500 |
| commit | e9d1f1182aaccaa8b60cf6a3491f0103d2bb0229 (patch) | |
| tree | 0271253f82ce9c1df9a77c43eb4d79bf4135f312 /django | |
| parent | cbb5cdd155668ba771cad6b975676d3b20fed37b (diff) | |
Fixed #23801 -- Added warning when max_length is used with IntegerField
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/fields/__init__.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 552f868de2..2c3efbb689 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -1704,6 +1704,23 @@ class IntegerField(Field): } description = _("Integer") + def check(self, **kwargs): + errors = super(IntegerField, self).check(**kwargs) + errors.extend(self._check_max_length_warning()) + return errors + + def _check_max_length_warning(self): + if self.max_length is not None: + return [ + checks.Warning( + "'max_length' is ignored when used with IntegerField", + hint="Remove 'max_length' from field", + obj=self, + id='fields.W122', + ) + ] + return [] + @cached_property def validators(self): # These validators can't be added at field initialization time since |
