Fixed #26557 -- Converted empty strings to None when saving GenericIPAddressField.

This commit is contained in:
Joshua Phillips 2016-04-29 11:44:56 +01:00 committed by Tim Graham
parent 2f698cd991
commit 4681d65048
3 changed files with 12 additions and 1 deletions

View file

@ -29,6 +29,14 @@ class GenericIPAddressFieldTests(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()