Supported multiple template engines in render_to_string.

Adjusted its API through a deprecation path according to the DEP.
This commit is contained in:
Aymeric Augustin 2014-11-28 23:50:34 +01:00
parent f9a6ebf6f5
commit 90805b240f
7 changed files with 146 additions and 27 deletions

View file

@ -890,7 +890,7 @@ When :setting:`TEMPLATE_DEBUG` is ``True`` template objects will have an
The ``render_to_string`` shortcut
===================================
.. function:: loader.render_to_string(template_name, dictionary=None, context_instance=None)
.. function:: loader.render_to_string(template_name, context=None, context_instance=None)
To cut down on the repetitive nature of loading and rendering
templates, Django provides a shortcut function which largely
@ -906,16 +906,25 @@ The ``render_to_string`` shortcut takes one required argument --
and render (or a list of template names, in which case Django will use
the first template in the list that exists) -- and two optional arguments:
dictionary
``context``
A dictionary to be used as variables and values for the
template's context. This can also be passed as the second
template's context. This should be passed as the second
positional argument.
context_instance
.. versionchanged:: 1.8
The ``context`` argument used to be called ``dictionary``. That name
is deprecated in Django 1.8 and will be removed in Django 2.0.
``context_instance``
An instance of :class:`~django.template.Context` or a subclass (e.g., an
instance of :class:`~django.template.RequestContext`) to use as the
template's context. This can also be passed as the third positional argument.
.. deprecated:: 1.8
The ``context_instance`` argument is deprecated. Simply use ``context``.
See also the :func:`~django.shortcuts.render_to_response()` shortcut, which
calls ``render_to_string`` and feeds the result into an :class:`~django.http.HttpResponse`
suitable for returning directly from a view.