mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #26557 -- Converted empty strings to None when saving GenericIPAddressField.
This commit is contained in:
parent
2f698cd991
commit
4681d65048
3 changed files with 12 additions and 1 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue