rest_framework_json_api.renderers module
Renderers
- class rest_framework_json_api.renderers.JSONRenderer
Bases:
JSONRenderer
The JSONRenderer exposes a number of methods that you may override if you need highly custom rendering control.
Render a JSON response per the JSON:API spec:
{ "data": [ { "type": "companies", "id": "1", "attributes": { "name": "Mozilla", "slug": "mozilla", "date-created": "2014-03-13 16:33:37" } } ] }
- media_type = 'application/vnd.api+json'
- format = 'vnd.api+json'
- classmethod extract_attributes(fields, resource)
Builds the attributes object of the JSON:API resource object.
- classmethod extract_relationships(fields, resource, resource_instance)
Builds the relationships top level object based on related serializers.
- classmethod extract_relation_instance(field, resource_instance)
Determines what instance represents given relation and extracts it.
Relation instance is determined exactly same way as it determined in parent serializer
- classmethod extract_included(fields, resource, resource_instance, included_resources, included_cache)
Adds related data to the top level included key when the request includes ?include=example,example_field2
- classmethod extract_meta(serializer, resource)
Gathers the data from serializer fields specified in meta_fields and adds it to the meta object.
- classmethod extract_root_meta(serializer, resource)
Calls a get_root_meta function on a serializer, if it exists.
- classmethod build_json_resource_obj(fields, resource, resource_instance, resource_name, serializer, force_type_resolution=False)
Builds the resource object (type, id, attributes) and extracts relationships.
- render_relationship_view(data, accepted_media_type=None, renderer_context=None)
- render_errors(data, accepted_media_type=None, renderer_context=None)
- render(data, accepted_media_type=None, renderer_context=None)