1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00

Default JSONField to empty dict if field does not allow None.

This commit is contained in:
Chris Church 2016-11-15 10:21:34 -05:00
parent 8dc5e7725c
commit 3eb6f55a80

View File

@ -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: