Пример #1
0
    def to_python(self, value):
        """Convert our string value to JSON after we load it from the DB"""
        if value in ("", None):
            return None

        try:
            if isinstance(value, basestring):
                return json.loads(value, object_hook=decode_object)
        except ValueError:
            pass

        return value
Пример #2
0
    def to_python(self, value):
        """Convert our string value to JSON after we load it from the DB"""
        if value == "":
            return None

        try:
            if isinstance(value, basestring):
                return json.loads(value, object_hook=decode_object)
        except ValueError:
            pass

        return value
Пример #3
0
    def to_python(self, value):
        """Convert our string value to JSON after we load it from the DB"""
        if value in ("", None):
            return None

        try:
            if isinstance(value, (str, unicode)):
                return json.loads(
                    value, object_hook=decode_object if self.pickle else None)
        except ValueError:
            pass

        return value
Пример #4
0
 def value_from_datadict(self, data, files, name):
     value = data.get(name, '').strip()
     if value in ['', None]:
         return {}
     return json.loads(value)
Пример #5
0
 def value_from_datadict(self, data, files, name):
     value = data.get(name, '').strip()
     if value in ['', None]:
         return {}
     return json.loads(value)