Skip to content

Commit 0a3bdf2

Browse files
committed
Merge pull request jimfunk#23 from sbrandtb/fix_mac_len
Check for string length on EUI causes error
2 parents b5b1f13 + e69cb6a commit 0a3bdf2

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

netfields/fields.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ def form_class(self):
9292
class MACAddressField(models.Field):
9393
description = "PostgreSQL MACADDR field"
9494

95-
def __init__(self, *args, **kwargs):
96-
kwargs['max_length'] = 17
97-
super(MACAddressField, self).__init__(*args, **kwargs)
98-
9995
def db_type(self, connection):
10096
return 'macaddr'
10197

netfields/forms.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,8 @@ def to_python(self, value):
8484
return EUI(value, dialect=mac_unix_common)
8585
except (AddrFormatError, TypeError):
8686
raise ValidationError(self.error_messages['invalid'])
87+
88+
def widget_attrs(self, widget):
89+
attrs = super(MACAddressFormField, self).widget_attrs(widget)
90+
attrs.update({'maxlength': '17'})
91+
return attrs

0 commit comments

Comments
 (0)