Просмотр исходного кода

Fixes #5109: Fix representation of custom choice field values for webhook data

Jeremy Stretch 5 лет назад
Родитель
Сommit
47a6fc19ca
2 измененных файлов с 2 добавлено и 1 удалено
  1. 1 0
      docs/release-notes/version-2.9.md
  2. 1 1
      netbox/extras/api/customfields.py

+ 1 - 0
docs/release-notes/version-2.9.md

@@ -5,6 +5,7 @@
 ### Bug Fixes
 
 * [#5050](https://github.com/netbox-community/netbox/issues/5050) - Fix potential failure on `0016_replicate_interfaces` schema migration from old release
+* [#5109](https://github.com/netbox-community/netbox/issues/5109) - Fix representation of custom choice field values for webhook data
 * [#5111](https://github.com/netbox-community/netbox/issues/5111) - Allow use of tuples when specifying ObjectVar `query_params`
 
 ---

+ 1 - 1
netbox/extras/api/customfields.py

@@ -158,7 +158,7 @@ class CustomFieldModelSerializer(ValidatedModelSerializer):
         instance.custom_fields = {}
         for field in custom_fields:
             value = instance.cf.get(field.name)
-            if field.type == CustomFieldTypeChoices.TYPE_SELECT and value:
+            if field.type == CustomFieldTypeChoices.TYPE_SELECT and type(value) is CustomFieldChoice:
                 instance.custom_fields[field.name] = CustomFieldChoiceSerializer(value).data
             else:
                 instance.custom_fields[field.name] = value