def render_to_json ( templates , context , request ) : html = render_to_string ( templates , context = context , request = request ) _json = json . dumps ( { "html" : html } ) return HttpResponse ( _json )
python rendering json, and html
Generate a JSON HttpResponse with rendered template HTML .
def render_to_json(templates, context, request):
    """
    Generate a JSON HttpResponse with rendered template HTML.
    """
    html = render_to_string(
        templates,
        context=context,
        request=request
    )
    _json = json.dumps({
        "html": html
    })
    return HttpResponse(_json)