Procházet zdrojové kódy

Fixes #1620: Loosen IP address search filter to match all IPs that start with the given string

Jeremy Stretch před 8 roky
rodič
revize
515645bb4d
1 změnil soubory, kde provedl 4 přidání a 6 odebrání
  1. 4 6
      netbox/ipam/filters.py

+ 4 - 6
netbox/ipam/filters.py

@@ -267,12 +267,10 @@ class IPAddressFilter(CustomFieldFilterSet, django_filters.FilterSet):
     def search(self, queryset, name, value):
         if not value.strip():
             return queryset
-        qs_filter = Q(description__icontains=value)
-        try:
-            ipaddress = str(IPNetwork(value.strip()))
-            qs_filter |= Q(address__net_host=ipaddress)
-        except (AddrFormatError, ValueError):
-            pass
+        qs_filter = (
+            Q(description__icontains=value) |
+            Q(address__istartswith=value)
+        )
         return queryset.filter(qs_filter)
 
     def search_by_parent(self, queryset, name, value):