mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 03:23:59 +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.'),
|
||||
}
|
||||
|
||||
def __init__(self, protocol='both', unpack_ipv4=False, **kwargs):
|
||||
def __init__(self, protocol='both', **kwargs):
|
||||
self.protocol = protocol.lower()
|
||||
self.unpack_ipv4 = unpack_ipv4
|
||||
self.unpack_ipv4 = (self.protocol == 'both')
|
||||
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)
|
||||
|
||||
def to_internal_value(self, data):
|
||||
if data and ':' in data:
|
||||
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:
|
||||
self.fail('invalid', value=data)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user