Skip to content

Commit

Permalink
#733: Fixed MAC address device filter
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Dec 7, 2016
1 parent cc6ae8e commit 3a6d7a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion netbox/dcim/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,11 @@ def search(self, queryset, value):
).distinct()

def _mac_address(self, queryset, value):
value = value.strip()
if not value:
return queryset
try:
return queryset.filter(interfaces__mac_address=value.strip()).distinct()
return queryset.filter(interfaces__mac_address=value).distinct()
except AddrFormatError:
return queryset.none()

Expand Down
2 changes: 1 addition & 1 deletion netbox/dcim/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ class DeviceFilterForm(BootstrapMixin, CustomFieldFilterForm):
platform = FilterChoiceField(queryset=Platform.objects.annotate(filter_count=Count('devices')),
to_field_name='slug', null_option=(0, 'None'))
status = forms.NullBooleanField(required=False, widget=forms.Select(choices=FORM_STATUS_CHOICES))
mac_address = forms.CharField(label='MAC address', required=False)
mac_address = forms.CharField(required=False, label='MAC address')


#
Expand Down

0 comments on commit 3a6d7a1

Please sign in to comment.