Fixed #26410 -- Added a docs example for loader.render_to_string().

This commit is contained in:
Tim Graham 2016-03-31 08:31:03 -04:00
parent 49f95cc0a0
commit a65fc6df89
1 changed files with 5 additions and 0 deletions

View File

@ -256,6 +256,11 @@ templates, Django provides a shortcut function which automates the process.
An optional :class:`~django.http.HttpRequest` that will be available An optional :class:`~django.http.HttpRequest` that will be available
during the template's rendering process. during the template's rendering process.
Usage example::
from django.template.loader import render_to_string
rendered = render_to_string('my_template.html', {'foo': 'bar'})
See also the :func:`~django.shortcuts.render()` shortcut which calls See also the :func:`~django.shortcuts.render()` shortcut which calls
:func:`render_to_string()` and feeds the result into an :func:`render_to_string()` and feeds the result into an
:class:`~django.http.HttpResponse` suitable for returning from a view. :class:`~django.http.HttpResponse` suitable for returning from a view.