From 3eb6f55a80038fa823ae7a43711258d9fd972dde Mon Sep 17 00:00:00 2001 From: Chris Church Date: Tue, 15 Nov 2016 10:21:34 -0500 Subject: [PATCH] Default JSONField to empty dict if field does not allow None. --- awx/main/fields.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/awx/main/fields.py b/awx/main/fields.py index 6778e304d0..91f59bab8a 100644 --- a/awx/main/fields.py +++ b/awx/main/fields.py @@ -33,6 +33,8 @@ __all__ = ['AutoOneToOneField', 'ImplicitRoleField', 'JSONField'] class JSONField(upstream_JSONField): def from_db_value(self, value, expression, connection, context): + if value in {'', None} and not self.null: + return {} return super(JSONField, self).from_db_value(value, expression, connection, context) # Based on AutoOneToOneField from django-annoying: