mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 17:47:04 +03:00
Remove unpack_ipv4 parameter
This commit is contained in:
parent
466575bee6
commit
d6effbf779
|
@ -661,17 +661,18 @@ class IPAddressField(CharField):
|
||||||
'invalid': _('Enter a valid IPv4 or IPv6 address.'),
|
'invalid': _('Enter a valid IPv4 or IPv6 address.'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, protocol='both', unpack_ipv4=False, **kwargs):
|
def __init__(self, protocol='both', **kwargs):
|
||||||
self.protocol = protocol.lower()
|
self.protocol = protocol.lower()
|
||||||
self.unpack_ipv4 = unpack_ipv4
|
self.unpack_ipv4 = (self.protocol == 'both')
|
||||||
super(IPAddressField, self).__init__(**kwargs)
|
super(IPAddressField, self).__init__(**kwargs)
|
||||||
validators, error_message = ip_address_validators(protocol, unpack_ipv4)
|
validators, error_message = ip_address_validators(protocol, self.unpack_ipv4)
|
||||||
self.validators.extend(validators)
|
self.validators.extend(validators)
|
||||||
|
|
||||||
def to_internal_value(self, data):
|
def to_internal_value(self, data):
|
||||||
if data and ':' in data:
|
if data and ':' in data:
|
||||||
try:
|
try:
|
||||||
return clean_ipv6_address(data, self.unpack_ipv4)
|
if self.protocol in ('both', 'ipv6'):
|
||||||
|
return clean_ipv6_address(data, self.unpack_ipv4)
|
||||||
except DjangoValidationError:
|
except DjangoValidationError:
|
||||||
self.fail('invalid', value=data)
|
self.fail('invalid', value=data)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user