The renderers module provides a set of renderers that can be plugged in to a Resource. A renderer is responsible for taking the output of a View and serializing it to a given media type. A Resource can have a number of renderers, allow the same content to be serialized in a number of different formats depending on the requesting client’s preferences, as specified in the HTTP Request’s Accept header.
Renderers are used to serialize a View’s output into specific media types.
Django REST framework also provides HTML and PlainText renderers that help self-document the API, by serializing the output along with documentation regarding the View, output status and headers, and providing forms and links depending on the allowed methods, renderers and parsers on the View.
All renderers must extend this class, set the media_type attribute, and override the render() method.
Returns True if this renderer is able to deal with the given accept media type.
The default implementation for this function is to check the accept argument against the media_type attribute set on the class to see if they match.
This may be overridden to provide for other behavior, but typically you’ll instead want to just set the media_type attribute on the class.
Given an object render it into a string.
The requested media type is also passed to this method, as it may contain parameters relevant to how the parser should render the output. EG: application/json; indent=4
By default render simply returns the output as-is. Override this method to provide for other behavior.
Renderer which serializes to JSONP
alias of JSONRenderer
A Base class provided for convenience.
Render the object simply by using the given template. To create a template renderer, subclass this class, and set the media_type and template attributes.
Renderer which provides a browsable HTML interface for an API. See the examples at http://api.django-rest-framework.org to see this in action.