mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-24 17:38:37 -06:00
Fixes #1620: Loosen IP address search filter to match all IPs that start with the given string
This commit is contained in:
parent
6ae6209457
commit
515645bb4d
@ -267,12 +267,10 @@ class IPAddressFilter(CustomFieldFilterSet, django_filters.FilterSet):
|
|||||||
def search(self, queryset, name, value):
|
def search(self, queryset, name, value):
|
||||||
if not value.strip():
|
if not value.strip():
|
||||||
return queryset
|
return queryset
|
||||||
qs_filter = Q(description__icontains=value)
|
qs_filter = (
|
||||||
try:
|
Q(description__icontains=value) |
|
||||||
ipaddress = str(IPNetwork(value.strip()))
|
Q(address__istartswith=value)
|
||||||
qs_filter |= Q(address__net_host=ipaddress)
|
)
|
||||||
except (AddrFormatError, ValueError):
|
|
||||||
pass
|
|
||||||
return queryset.filter(qs_filter)
|
return queryset.filter(qs_filter)
|
||||||
|
|
||||||
def search_by_parent(self, queryset, name, value):
|
def search_by_parent(self, queryset, name, value):
|
||||||
|
Loading…
Reference in New Issue
Block a user