From d849e8189156e6580b28bbf3b0ef2d590fa8f5ab Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Thu, 5 Mar 2020 16:45:38 -0500 Subject: [PATCH] Show API choice field metadata more correctly for null vs '' --- awx/api/metadata.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/awx/api/metadata.py b/awx/api/metadata.py index 144aea3012..dba633a13c 100644 --- a/awx/api/metadata.py +++ b/awx/api/metadata.py @@ -101,8 +101,10 @@ class Metadata(metadata.SimpleMetadata): (choice_value, choice_name) for choice_value, choice_name in field.choices.items() ] if not any(choice in ('', None) for choice, _ in choices): - if field.allow_blank or (field.allow_null and not isinstance(field, ChoiceNullField)): + if field.allow_blank: choices = [("", "---------")] + choices + if field.allow_null and not isinstance(field, ChoiceNullField): + choices = [(None, "---------")] + choices field_info['choices'] = choices # Indicate if a field is write-only.