mirror of
https://github.com/ansible/awx.git
synced 2026-05-10 02:47:36 -02:30
work around a DRF issue that causes CharField to cast None to "None"
see: #5322
This commit is contained in:
@@ -19,6 +19,18 @@ logger = logging.getLogger('awx.conf.fields')
|
||||
# appropriate Python type to be used in settings.
|
||||
|
||||
|
||||
class CharField(CharField):
|
||||
|
||||
def to_representation(self, value):
|
||||
# django_rest_frameworks' default CharField implementation casts `None`
|
||||
# to a string `"None"`:
|
||||
#
|
||||
# https://github.com/tomchristie/django-rest-framework/blob/cbad236f6d817d992873cd4df6527d46ab243ed1/rest_framework/fields.py#L761
|
||||
if value is None:
|
||||
return None
|
||||
return super(CharField, self).to_representation(value)
|
||||
|
||||
|
||||
class StringListField(ListField):
|
||||
|
||||
child = CharField()
|
||||
|
||||
Reference in New Issue
Block a user