From 3a2046b63c94c2575c13b1738da13e953a7f4a61 Mon Sep 17 00:00:00 2001 From: Brian Tiemann Date: Thu, 19 Sep 2024 20:42:34 -0400 Subject: [PATCH] Also remove 'null_value' from extra (maybe will need to remove more) --- netbox/netbox/filtersets.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/netbox/netbox/filtersets.py b/netbox/netbox/filtersets.py index 807a7ea03..e3bd33298 100644 --- a/netbox/netbox/filtersets.py +++ b/netbox/netbox/filtersets.py @@ -180,11 +180,9 @@ class BaseFilterSet(django_filters.FilterSet): # create the new filter with the same type because there is no guarantee the defined type # is the same as the default type for the field resolve_field(field, lookup_expr) # Will raise FieldLookupError if the lookup is invalid - if lookup_expr == 'empty': - existing_filter_extra.pop('choices', None) - filter_cls = django_filters.BooleanFilter - else: - filter_cls = type(existing_filter) + for field_to_remove in ('choices', 'null_value'): + existing_filter_extra.pop(field_to_remove, None) + filter_cls = django_filters.BooleanFilter if lookup_expr == 'empty' else type(existing_filter) new_filter = filter_cls( field_name=field_name, lookup_expr=lookup_expr,