rest_framework_json_api.renderers module
Renderers
- classrest_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'
- classmethodextract_attributes(fields, resource)
Builds the attributes object of the JSON:API resource object.
Ensures that ID which is always provided in a JSON:API resource object and relationships are not returned.
- classmethodextract_relationships(fields, resource, resource_instance)
Builds the relationships top level object based on related serializers.
- classmethodextract_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
- classmethodextract_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
- classmethodextract_meta(serializer, resource)
Gathers the data from serializer fields specified in meta_fields and adds it to the meta object.
- classmethodextract_root_meta(serializer, resource)
Calls a get_root_meta function on a serializer, if it exists.
- classmethodbuild_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)