mirror of
https://github.com/ansible/awx.git
synced 2026-09-03 02:18:28 -02:30
New method to monkeypatch JSONField
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user