def render_to_string(template_name, context=None, context_instance=None, response_format='html'):
    if context is None:
        context = {}
    if not response_format or 'pdf' in response_format or response_format not in settings.HARDTREE_RESPONSE_FORMATS:
        response_format = 'html'

    if not ("." + response_format) in template_name:
        template_name += "." + response_format

    template_name = response_format + "/" + template_name

    context['response_format'] = response_format
    if context_instance:
        context['site_domain'] = RequestSite(
            context_instance['request']).domain

    context = _preprocess_context_html(context)

    rendered_string = loader.render_to_string(
        template_name, context, context_instance)
    return rendered_string
inspect.getargspec replacement for compatibility with python 3.x.
dataset/ETHPy150Open treeio/treeio/treeio/core/rendering.py/render_to_string--crossover with--dataset/ETHPy150Open scipy/scipy/scipy/_lib/_util.py/getargspec_no_self