mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 17:26:10 -06:00
#12278 fix to_internal_value to_representation in serializer
This commit is contained in:
parent
fb1827cac1
commit
95e37e47cc
@ -6,6 +6,7 @@ from ipam import models
|
||||
from ipam.models.l2vpn import L2VPNTermination, L2VPN
|
||||
from ipam.validators import validate_ipaddress_with_mask
|
||||
from netbox.api.serializers import WritableNestedSerializer
|
||||
from netaddr import IPNetwork
|
||||
|
||||
__all__ = [
|
||||
'IPAddressField',
|
||||
@ -46,6 +47,12 @@ class IPAddressField(serializers.CharField):
|
||||
validator = validate_ipaddress_with_mask
|
||||
self.validators.append(validator)
|
||||
|
||||
def to_internal_value(self, data):
|
||||
return IPNetwork(data)
|
||||
|
||||
def to_representation(self, value):
|
||||
return str(value)
|
||||
|
||||
|
||||
#
|
||||
# ASN ranges
|
||||
|
Loading…
Reference in New Issue
Block a user