'Extracts the common "which-format/serialize/return-response" cycle.
Mostly a useful shortcut/hook.'

def create_response(self, request, data, response_class=HttpResponse, **response_kwargs):

    desired_format = self.determine_format(request)
    serialized = self.serialize(request, data, desired_format)
    return response_class(content=serialized, content_type=build_content_type(desired_format), **response_kwargs)
