mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
Fixes #2684: Fix custom field filtering
This commit is contained in:
parent
2418fed65b
commit
edd763b1aa
@ -12,6 +12,7 @@ v2.5.1 (FUTURE)
|
|||||||
* [#2676](https://github.com/digitalocean/netbox/issues/2676) - Fix exception when passing dictionary value to a ChoiceField
|
* [#2676](https://github.com/digitalocean/netbox/issues/2676) - Fix exception when passing dictionary value to a ChoiceField
|
||||||
* [#2678](https://github.com/digitalocean/netbox/issues/2678) - Fix error when viewing webhook in admin UI without write permission
|
* [#2678](https://github.com/digitalocean/netbox/issues/2678) - Fix error when viewing webhook in admin UI without write permission
|
||||||
* [#2680](https://github.com/digitalocean/netbox/issues/2680) - Disallow POST requests to `/dcim/interface-connections/` API endpoint
|
* [#2680](https://github.com/digitalocean/netbox/issues/2680) - Disallow POST requests to `/dcim/interface-connections/` API endpoint
|
||||||
|
* [#2684](https://github.com/digitalocean/netbox/issues/2684) - Fix custom field filtering
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -31,12 +31,12 @@ class CustomFieldFilter(django_filters.Filter):
|
|||||||
# Treat 0 as None
|
# Treat 0 as None
|
||||||
if int(value) == 0:
|
if int(value) == 0:
|
||||||
return queryset.exclude(
|
return queryset.exclude(
|
||||||
custom_field_values__field__name=self.name,
|
custom_field_values__field__name=self.field_name,
|
||||||
)
|
)
|
||||||
# Match on exact CustomFieldChoice PK
|
# Match on exact CustomFieldChoice PK
|
||||||
else:
|
else:
|
||||||
return queryset.filter(
|
return queryset.filter(
|
||||||
custom_field_values__field__name=self.name,
|
custom_field_values__field__name=self.field_name,
|
||||||
custom_field_values__serialized_value=value,
|
custom_field_values__serialized_value=value,
|
||||||
)
|
)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
@ -45,12 +45,12 @@ class CustomFieldFilter(django_filters.Filter):
|
|||||||
# Apply the assigned filter logic (exact or loose)
|
# Apply the assigned filter logic (exact or loose)
|
||||||
if self.cf_type == CF_TYPE_BOOLEAN or self.filter_logic == CF_FILTER_EXACT:
|
if self.cf_type == CF_TYPE_BOOLEAN or self.filter_logic == CF_FILTER_EXACT:
|
||||||
queryset = queryset.filter(
|
queryset = queryset.filter(
|
||||||
custom_field_values__field__name=self.name,
|
custom_field_values__field__name=self.field_name,
|
||||||
custom_field_values__serialized_value=value
|
custom_field_values__serialized_value=value
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
queryset = queryset.filter(
|
queryset = queryset.filter(
|
||||||
custom_field_values__field__name=self.name,
|
custom_field_values__field__name=self.field_name,
|
||||||
custom_field_values__serialized_value__icontains=value
|
custom_field_values__serialized_value__icontains=value
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user