mirror of https://github.com/django/django.git
Fixed #16246 -- Fixed GenericIPAddressField tests on PostgreSQL.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16395 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
479f2bce3c
commit
823bac36db
|
@ -910,6 +910,7 @@ class BigIntegerField(IntegerField):
|
||||||
empty_strings_allowed = False
|
empty_strings_allowed = False
|
||||||
description = _("Big (8 byte) integer")
|
description = _("Big (8 byte) integer")
|
||||||
MAX_BIGINT = 9223372036854775807
|
MAX_BIGINT = 9223372036854775807
|
||||||
|
|
||||||
def get_internal_type(self):
|
def get_internal_type(self):
|
||||||
return "BigIntegerField"
|
return "BigIntegerField"
|
||||||
|
|
||||||
|
@ -922,6 +923,7 @@ class BigIntegerField(IntegerField):
|
||||||
class IPAddressField(Field):
|
class IPAddressField(Field):
|
||||||
empty_strings_allowed = False
|
empty_strings_allowed = False
|
||||||
description = _("IPv4 address")
|
description = _("IPv4 address")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
kwargs['max_length'] = 15
|
kwargs['max_length'] = 15
|
||||||
Field.__init__(self, *args, **kwargs)
|
Field.__init__(self, *args, **kwargs)
|
||||||
|
@ -956,6 +958,11 @@ class GenericIPAddressField(Field):
|
||||||
self.unpack_ipv4, self.error_messages['invalid'])
|
self.unpack_ipv4, self.error_messages['invalid'])
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
def get_db_prep_value(self, value, connection, prepared=False):
|
||||||
|
if not prepared:
|
||||||
|
value = self.get_prep_value(value)
|
||||||
|
return value or None
|
||||||
|
|
||||||
def get_prep_value(self, value):
|
def get_prep_value(self, value):
|
||||||
if value and ':' in value:
|
if value and ':' in value:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -965,8 +965,8 @@ class GenericIPAddressField(CharField):
|
||||||
super(GenericIPAddressField, self).__init__(*args, **kwargs)
|
super(GenericIPAddressField, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
def to_python(self, value):
|
def to_python(self, value):
|
||||||
if not value:
|
if value in validators.EMPTY_VALUES:
|
||||||
return ''
|
return u''
|
||||||
if value and ':' in value:
|
if value and ':' in value:
|
||||||
return clean_ipv6_address(value,
|
return clean_ipv6_address(value,
|
||||||
self.unpack_ipv4, self.error_messages['invalid'])
|
self.unpack_ipv4, self.error_messages['invalid'])
|
||||||
|
|
|
@ -84,9 +84,9 @@ class UniqueErrorsModel(models.Model):
|
||||||
number = models.IntegerField(unique=True, error_messages={'unique': u'Custom unique number message.'})
|
number = models.IntegerField(unique=True, error_messages={'unique': u'Custom unique number message.'})
|
||||||
|
|
||||||
class GenericIPAddressTestModel(models.Model):
|
class GenericIPAddressTestModel(models.Model):
|
||||||
generic_ip = models.GenericIPAddressField(blank=True, unique=True)
|
generic_ip = models.GenericIPAddressField(blank=True, null=True, unique=True)
|
||||||
v4_ip = models.GenericIPAddressField(blank=True, protocol="ipv4")
|
v4_ip = models.GenericIPAddressField(blank=True, null=True, protocol="ipv4")
|
||||||
v6_ip = models.GenericIPAddressField(blank=True, protocol="ipv6")
|
v6_ip = models.GenericIPAddressField(blank=True, null=True, protocol="ipv6")
|
||||||
|
|
||||||
class GenericIPAddrUnpackUniqueTest(models.Model):
|
class GenericIPAddrUnpackUniqueTest(models.Model):
|
||||||
generic_v4unpack_ip = models.GenericIPAddressField(blank=True, unique=True, unpack_ipv4=True)
|
generic_v4unpack_ip = models.GenericIPAddressField(blank=True, unique=True, unpack_ipv4=True)
|
||||||
|
|
Loading…
Reference in New Issue