Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions netbox/netbox/api/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ def validate_empty_values(self, data):
return super().validate_empty_values(data)

def to_representation(self, obj):
if obj == '':
return None
return {
'value': obj,
'label': self._choices[obj],
}
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, ''),
}

def to_internal_value(self, data):
if data == '':
Expand Down