summaryrefslogtreecommitdiff
path: root/tests/model_fields
diff options
context:
space:
mode:
authorJoshua Phillips <jphillips@imap.cc>2016-04-29 11:44:56 +0100
committerTim Graham <timograham@gmail.com>2016-04-29 10:14:48 -0400
commite0af590bdecfa3a5f013715f01456cfb8fd870dc (patch)
treead71e54339d85a7e33eca5a14a12489fdd9a7807 /tests/model_fields
parentd2338bae786f2fabfd01c30522fda9d79e02eb45 (diff)
[1.9.x] Fixed #26557 -- Converted empty strings to None when saving GenericIPAddressField.
Backport of 4681d65048ca2553895e10c2c492997b0a78ffba from master
Diffstat (limited to 'tests/model_fields')
-rw-r--r--tests/model_fields/tests.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py
index cc6639b032..b103baeedb 100644
--- a/tests/model_fields/tests.py
+++ b/tests/model_fields/tests.py
@@ -900,6 +900,14 @@ class GenericIPAddressFieldTests(test.TestCase):
o = GenericIPAddress.objects.get()
self.assertIsNone(o.ip)
+ def test_blank_string_saved_as_null(self):
+ o = GenericIPAddress.objects.create(ip='')
+ o.refresh_from_db()
+ self.assertIsNone(o.ip)
+ GenericIPAddress.objects.update(ip='')
+ o.refresh_from_db()
+ self.assertIsNone(o.ip)
+
def test_save_load(self):
instance = GenericIPAddress.objects.create(ip='::1')
loaded = GenericIPAddress.objects.get()