From 2bae50f50184b6d395f19b2c8ff2b696f3505527 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 26 Nov 2018 14:02:38 -0500 Subject: [PATCH] Enforce consistent ordering of value/label keys for ChoiceField --- netbox/utilities/api.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/netbox/utilities/api.py b/netbox/utilities/api.py index 429c34a19..b788e957e 100644 --- a/netbox/utilities/api.py +++ b/netbox/utilities/api.py @@ -71,7 +71,11 @@ class ChoiceField(Field): def to_representation(self, obj): if obj is '': return None - return {'value': obj, 'label': self._choices[obj]} + data = OrderedDict([ + ('value', obj), + ('label', self._choices[obj]) + ]) + return data def to_internal_value(self, data): # Hotwiring boolean values