Django Rest Framework
0
Вклад в тег
ret = json.dumps(
data, cls=self.encoder_class,
indent=indent, ensure_ascii=self.ensure_ascii,
separators=separators
)
if self.requires_serializing is True:
ret = json.dumps(
data, cls=self.encoder_class,
indent=indent, ensure_ascii=self.ensure_ascii,
separators=separators
)
elif type(data) is str:
ret = data
else:
raise TypeError('JSONStringPassRenderer::render \
-> requires_serializing field set to FALSE, but passed @data argument type is not a string')
class CustomJSONView(ApiView):
special_renderer = JSONStringPassRenderer
renderer_classes = (special_renderer, BrowsableAPIRenderer)
self.special_renderer.requires_serializing = False