Loading django/db/models/fields/__init__.py +1 −1 Original line number Diff line number Diff line Loading @@ -1910,7 +1910,7 @@ class IPAddressField(Field): class GenericIPAddressField(Field): empty_strings_allowed = True empty_strings_allowed = False description = _("IP address") default_error_messages = {} Loading docs/releases/1.8.txt +5 −0 Original line number Diff line number Diff line Loading @@ -1009,6 +1009,11 @@ Miscellaneous different in some cases. There is no change to default values which are the result of a callable. * ``GenericIPAddressField.empty_strings_allowed`` is now ``False``. Database backends that interpet empty strings as null (only Oracle among the backends that Django includes) will no longer convert null values back to an empty string. This is consistent with other backends. .. _deprecated-features-1.8: Features deprecated in 1.8 Loading tests/model_fields/models.py +4 −0 Original line number Diff line number Diff line Loading @@ -176,6 +176,10 @@ class VerboseNameField(models.Model): field22 = models.URLField("verbose field22") class GenericIPAddress(models.Model): ip = models.GenericIPAddressField(null=True, protocol='ipv4') ############################################################################### # These models aren't used in any test, just here to ensure they validate # successfully. Loading tests/model_fields/tests.py +13 −5 Original line number Diff line number Diff line Loading @@ -22,11 +22,11 @@ from django.utils import six from django.utils.functional import lazy from .models import ( Foo, Bar, Whiz, BigD, BigS, BigIntegerModel, Post, NullBooleanModel, BooleanModel, PrimaryKeyCharModel, DataModel, Document, RenamedField, DateTimeModel, VerboseNameField, FksToBooleans, FkToChar, FloatModel, SmallIntegerModel, IntegerModel, PositiveSmallIntegerModel, PositiveIntegerModel, WhizIter, WhizIterEmpty) Bar, BigD, BigIntegerModel, BigS, BooleanModel, DataModel, DateTimeModel, Document, FksToBooleans, FkToChar, FloatModel, Foo, GenericIPAddress, IntegerModel, NullBooleanModel, PositiveIntegerModel, PositiveSmallIntegerModel, Post, PrimaryKeyCharModel, RenamedField, SmallIntegerModel, VerboseNameField, Whiz, WhizIter, WhizIterEmpty) class BasicFieldTests(test.TestCase): Loading Loading @@ -688,6 +688,14 @@ class GenericIPAddressFieldTests(test.TestCase): form_field = model_field.formfield() self.assertRaises(ValidationError, form_field.clean, '127.0.0.1') def test_null_value(self): """ Null values should be resolved to None in Python (#24078). """ GenericIPAddress.objects.create() o = GenericIPAddress.objects.get() self.assertIsNone(o.ip) class PromiseTest(test.TestCase): def test_AutoField(self): Loading Loading
django/db/models/fields/__init__.py +1 −1 Original line number Diff line number Diff line Loading @@ -1910,7 +1910,7 @@ class IPAddressField(Field): class GenericIPAddressField(Field): empty_strings_allowed = True empty_strings_allowed = False description = _("IP address") default_error_messages = {} Loading
docs/releases/1.8.txt +5 −0 Original line number Diff line number Diff line Loading @@ -1009,6 +1009,11 @@ Miscellaneous different in some cases. There is no change to default values which are the result of a callable. * ``GenericIPAddressField.empty_strings_allowed`` is now ``False``. Database backends that interpet empty strings as null (only Oracle among the backends that Django includes) will no longer convert null values back to an empty string. This is consistent with other backends. .. _deprecated-features-1.8: Features deprecated in 1.8 Loading
tests/model_fields/models.py +4 −0 Original line number Diff line number Diff line Loading @@ -176,6 +176,10 @@ class VerboseNameField(models.Model): field22 = models.URLField("verbose field22") class GenericIPAddress(models.Model): ip = models.GenericIPAddressField(null=True, protocol='ipv4') ############################################################################### # These models aren't used in any test, just here to ensure they validate # successfully. Loading
tests/model_fields/tests.py +13 −5 Original line number Diff line number Diff line Loading @@ -22,11 +22,11 @@ from django.utils import six from django.utils.functional import lazy from .models import ( Foo, Bar, Whiz, BigD, BigS, BigIntegerModel, Post, NullBooleanModel, BooleanModel, PrimaryKeyCharModel, DataModel, Document, RenamedField, DateTimeModel, VerboseNameField, FksToBooleans, FkToChar, FloatModel, SmallIntegerModel, IntegerModel, PositiveSmallIntegerModel, PositiveIntegerModel, WhizIter, WhizIterEmpty) Bar, BigD, BigIntegerModel, BigS, BooleanModel, DataModel, DateTimeModel, Document, FksToBooleans, FkToChar, FloatModel, Foo, GenericIPAddress, IntegerModel, NullBooleanModel, PositiveIntegerModel, PositiveSmallIntegerModel, Post, PrimaryKeyCharModel, RenamedField, SmallIntegerModel, VerboseNameField, Whiz, WhizIter, WhizIterEmpty) class BasicFieldTests(test.TestCase): Loading Loading @@ -688,6 +688,14 @@ class GenericIPAddressFieldTests(test.TestCase): form_field = model_field.formfield() self.assertRaises(ValidationError, form_field.clean, '127.0.0.1') def test_null_value(self): """ Null values should be resolved to None in Python (#24078). """ GenericIPAddress.objects.create() o = GenericIPAddress.objects.get() self.assertIsNone(o.ip) class PromiseTest(test.TestCase): def test_AutoField(self): Loading