We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 099aff5 commit 3cb41bbCopy full SHA for 3cb41bb
netbox/netbox/api/fields.py
@@ -46,12 +46,13 @@ def validate_empty_values(self, data):
46
return super().validate_empty_values(data)
47
48
def to_representation(self, obj):
49
- if obj == '':
50
- return None
51
- return {
52
- 'value': obj,
53
- 'label': self._choices[obj],
54
- }
+ if obj != '':
+ # Use an empty string in place of the choice label if it cannot be resolved (i.e. because a previously
+ # configured choice has been removed from FIELD_CHOICES).
+ return {
+ 'value': obj,
+ 'label': self._choices.get(obj, ''),
55
+ }
56
57
def to_internal_value(self, data):
58
if data == '':
0 commit comments