MCPcopy Create free account
hub / github.com/encode/django-rest-framework / JSONBoundField

Class JSONBoundField

rest_framework/utils/serializer_helpers.py:98–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96
97
98class JSONBoundField(BoundField):
99 def as_form_field(self):
100 value = self.value
101 # When HTML form input is used and the input is not valid
102 # value will be a JSONString, rather than a JSON primitive.
103 if not getattr(value, 'is_json_string', False):
104 with contextlib.suppress(TypeError, ValueError):
105 value = json.dumps(
106 self.value,
107 sort_keys=True,
108 indent=4,
109 separators=(',', ': '),
110 )
111 return self.__class__(self._field, value, self.errors, self._prefix)
112
113
114class NestedBoundField(BoundField):

Callers 2

__getitem__Method · 0.90
__getitem__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected