Browse Source

Fixes #7324: Fix TypeError exception in web UI when filtering objects using single-choice filters

jeremystretch 4 years ago
parent
commit
41dfdc0aaa
2 changed files with 8 additions and 0 deletions
  1. 6 0
      docs/release-notes/version-3.0.md
  2. 2 0
      netbox/utilities/forms/utils.py

+ 6 - 0
docs/release-notes/version-3.0.md

@@ -1,5 +1,11 @@
 # NetBox v3.0
 # NetBox v3.0
 
 
+## v3.0.4 (FUTURE)
+
+### Bug Fixes
+
+* [#7324](https://github.com/netbox-community/netbox/issues/7324) - Fix TypeError exception in web UI when filtering objects using single-choice filters
+
 ## v3.0.3 (2021-09-20)
 ## v3.0.3 (2021-09-20)
 
 
 ### Enhancements
 ### Enhancements

+ 2 - 0
netbox/utilities/forms/utils.py

@@ -137,6 +137,8 @@ def get_selected_values(form, field_name):
     else:
     else:
         # Static selection field
         # Static selection field
         choices = unpack_grouped_choices(field.choices)
         choices = unpack_grouped_choices(field.choices)
+        if type(filter_data) not in (list, tuple):
+            filter_data = [filter_data]  # Ensure filter data is iterable
         values = [
         values = [
             label for value, label in choices if str(value) in filter_data or None in filter_data
             label for value, label in choices if str(value) in filter_data or None in filter_data
         ]
         ]