summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2013-05-28 15:11:41 -0400
committerTim Graham <timograham@gmail.com>2013-05-28 15:12:47 -0400
commitded95ccdce0ba983c405ddde9eb071e454245a94 (patch)
tree1f0ebc0a4bb36b01b0e8a830acbe08964b278d73 /django
parenta2967d5204729771e3716c431ea98f8ee8562d3e (diff)
Fixed #20484 -- Added model validation for GenericIPAddressField
GenericIPAddressField must not allow blank for NOT NULL fields Thanks Erik Romijn.
Diffstat (limited to 'django')
-rw-r--r--django/core/management/validation.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/django/core/management/validation.py b/django/core/management/validation.py
index 2040a14582..a6d6a76985 100644
--- a/django/core/management/validation.py
+++ b/django/core/management/validation.py
@@ -113,6 +113,8 @@ def get_validation_errors(outfile, app=None):
e.add(opts, '"%s": BooleanFields do not accept null values. Use a NullBooleanField instead.' % f.name)
if isinstance(f, models.FilePathField) and not (f.allow_files or f.allow_folders):
e.add(opts, '"%s": FilePathFields must have either allow_files or allow_folders set to True.' % f.name)
+ if isinstance(f, models.GenericIPAddressField) and not getattr(f, 'null', False) and getattr(f, 'blank', False):
+ e.add(opts, '"%s": GenericIPAddressField can not accept blank values if null values are not allowed, as blank values are stored as null.' % f.name)
if f.choices:
if isinstance(f.choices, six.string_types) or not is_iterable(f.choices):
e.add(opts, '"%s": "choices" should be iterable (e.g., a tuple or list).' % f.name)