MCPcopy Index your code
hub / github.com/encode/django-rest-framework / get_content

Method get_content

rest_framework/renderers.py:426–444  ·  view source on GitHub ↗

Get the content as if it had been rendered by the default non-documenting renderer.

(self, renderer, data,
                    accepted_media_type, renderer_context)

Source from the content-addressed store, hash-verified

424 return renderers[0]()
425
426 def get_content(self, renderer, data,
427 accepted_media_type, renderer_context):
428 """
429 Get the content as if it had been rendered by the default
430 non-documenting renderer.
431 """
432 if not renderer:
433 return '[No renderers were found]'
434
435 renderer_context['indent'] = 4
436 content = renderer.render(data, accepted_media_type, renderer_context)
437
438 render_style = getattr(renderer, 'render_style', 'text')
439 assert render_style in ['text', 'binary'], 'Expected .render_style ' \
440 '"text" or "binary", but got "%s"' % render_style
441 if render_style == 'binary':
442 return '[%d bytes of binary content]' % len(content)
443
444 return content.decode('utf-8') if isinstance(content, bytes) else content
445
446 def show_form_for_method(self, view, method, request, obj):
447 """

Callers 1

get_contextMethod · 0.95

Calls 1

renderMethod · 0.45

Tested by

no test coverage detected