mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Force 48-bit MAC format for proper error messages during validation
This commit is contained in:
@ -20,10 +20,10 @@ class MACAddressField(models.Field):
|
||||
return self.to_python(value)
|
||||
|
||||
def to_python(self, value):
|
||||
if not value:
|
||||
if value is None:
|
||||
return value
|
||||
try:
|
||||
return EUI(value, dialect=mac_unix_expanded_uppercase)
|
||||
return EUI(value, version=48, dialect=mac_unix_expanded_uppercase)
|
||||
except ValueError as e:
|
||||
raise ValidationError(e)
|
||||
|
||||
|
@ -21,6 +21,6 @@ class MACAddressFormField(forms.Field):
|
||||
return value
|
||||
|
||||
try:
|
||||
return EUI(value)
|
||||
return EUI(value, version=48)
|
||||
except AddrFormatError:
|
||||
raise ValidationError("Please specify a valid MAC address.")
|
||||
|
Reference in New Issue
Block a user