love too computer (jsonfield related hotfix)

master
alice 4 years ago
parent c0530b906d
commit c2a55e8b5c

@ -4,6 +4,7 @@ from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from jsonfield import JSONField
from datetime import timedelta
import json
from ccvpn.common import get_price
from .backends import BackendBase
@ -103,6 +104,10 @@ class BackendData:
""" adds a backend data key to this instance's dict """
if not self.backend_data:
self.backend_data = {}
if isinstance(self.backend_data, str):
self.backend_data = json.loads(self.backend_data) or {}
if not isinstance(self.backend_data, dict):
raise Exception("self.backend_data is not a dict (%r)" % self.backend_data)
self.backend_data[key] = value

Loading…
Cancel
Save