Force 48-bit MAC format for proper error messages during validation

This commit is contained in:
Jeremy Stretch
2016-07-06 14:22:34 -04:00
parent b8112483e5
commit 24b60fc1d3
2 changed files with 3 additions and 3 deletions

View File

@@ -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)