mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-30 04:16:24 -06:00
Move new field check into lookup_map iteration
This commit is contained in:
parent
8e27d2b7bf
commit
8d91407dcf
@ -168,8 +168,6 @@ class BaseFilterSet(django_filters.FilterSet):
|
|||||||
# Get properties of the existing filter for later use
|
# Get properties of the existing filter for later use
|
||||||
field_name = existing_filter.field_name
|
field_name = existing_filter.field_name
|
||||||
field = get_model_field(cls._meta.model, field_name)
|
field = get_model_field(cls._meta.model, field_name)
|
||||||
if field is None:
|
|
||||||
raise ValueError('Invalid field name/lookup on {}: {}'.format(existing_filter_name, field_name))
|
|
||||||
|
|
||||||
# Create new filters for each lookup expression in the map
|
# Create new filters for each lookup expression in the map
|
||||||
for lookup_name, lookup_expr in lookup_map.items():
|
for lookup_name, lookup_expr in lookup_map.items():
|
||||||
@ -181,6 +179,8 @@ class BaseFilterSet(django_filters.FilterSet):
|
|||||||
# The filter field has been explicitly defined on the filterset class so we must manually
|
# The filter field has been explicitly defined on the filterset class so we must manually
|
||||||
# create the new filter with the same type because there is no guarantee the defined type
|
# 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
|
# is the same as the default type for the field
|
||||||
|
if field is None:
|
||||||
|
raise ValueError('Invalid field name/lookup on {}: {}'.format(existing_filter_name, field_name))
|
||||||
resolve_field(field, lookup_expr) # Will raise FieldLookupError if the lookup is invalid
|
resolve_field(field, lookup_expr) # Will raise FieldLookupError if the lookup is invalid
|
||||||
filter_cls = type(existing_filter)
|
filter_cls = type(existing_filter)
|
||||||
if lookup_expr == 'empty':
|
if lookup_expr == 'empty':
|
||||||
|
Loading…
Reference in New Issue
Block a user