New method to monkeypatch JSONField

This commit is contained in:
AlanCoding
2016-11-14 13:07:00 -05:00
parent 0c2d9e09b9
commit 339661a6a5
12 changed files with 130 additions and 24 deletions

View File

@@ -19,14 +19,24 @@ from django.db.models.fields.related import (
)
from django.utils.encoding import smart_text
# Django-JSONField
from jsonfield import JSONField as upstream_JSONField
# AWX
from awx.main.models.rbac import batch_role_ancestor_rebuilding, Role
from awx.main.utils import get_current_apps
__all__ = ['AutoOneToOneField', 'ImplicitRoleField']
__all__ = ['AutoOneToOneField', 'ImplicitRoleField', 'JSONField']
class JSONField(upstream_JSONField):
def from_db_value(self, value, expression, connection, context):
if value in ['', None]:
return {}
return super(JSONField, self).from_db_value(value, expression, connection, context)
# Based on AutoOneToOneField from django-annoying:
# https://bitbucket.org/offline/django-annoying/src/a0de8b294db3/annoying/fields.py