mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 12:12:53 -06:00
Restored search method on prefix filter
This commit is contained in:
parent
593ae295e3
commit
c3e5106b04
@ -167,6 +167,17 @@ class PrefixFilter(CustomFieldFilterSet, django_filters.FilterSet):
|
|||||||
model = Prefix
|
model = Prefix
|
||||||
fields = ['family', 'is_pool']
|
fields = ['family', 'is_pool']
|
||||||
|
|
||||||
|
def search(self, queryset, name, value):
|
||||||
|
if not value.strip():
|
||||||
|
return queryset
|
||||||
|
qs_filter = Q(description__icontains=value)
|
||||||
|
try:
|
||||||
|
prefix = str(IPNetwork(value.strip()).cidr)
|
||||||
|
qs_filter |= Q(prefix__net_contains_or_equals=prefix)
|
||||||
|
except (AddrFormatError, ValueError):
|
||||||
|
pass
|
||||||
|
return queryset.filter(qs_filter)
|
||||||
|
|
||||||
def search_within(self, queryset, name, value):
|
def search_within(self, queryset, name, value):
|
||||||
value = value.strip()
|
value = value.strip()
|
||||||
if not value:
|
if not value:
|
||||||
|
Loading…
Reference in New Issue
Block a user