|
@@ -15,14 +15,13 @@ introduce controlled coupling for convenience's sake.
|
|
``render``
|
|
``render``
|
|
==========
|
|
==========
|
|
|
|
|
|
-.. function:: render(request, template_name, context=None, context_instance=_context_instance_undefined, content_type=None, status=None, using=None)
|
|
+.. function:: render(request, template_name, context=None, content_type=None, status=None, using=None)
|
|
|
|
|
|
Combines a given template with a given context dictionary and returns an
|
|
Combines a given template with a given context dictionary and returns an
|
|
:class:`~django.http.HttpResponse` object with that rendered text.
|
|
:class:`~django.http.HttpResponse` object with that rendered text.
|
|
|
|
|
|
- :func:`render()` is the same as a call to
|
|
+ :func:`render()` is the same as a call to :func:`render_to_response()` but
|
|
- :func:`render_to_response()` with a ``context_instance`` argument that
|
|
+ it also makes the current request available in the template.
|
|
- forces the use of a :class:`~django.template.RequestContext`.
|
|
|
|
|
|
|
|
Django does not provide a shortcut function which returns a
|
|
Django does not provide a shortcut function which returns a
|
|
:class:`~django.template.response.TemplateResponse` because the constructor
|
|
:class:`~django.template.response.TemplateResponse` because the constructor
|
|
@@ -46,20 +45,6 @@ Optional arguments
|
|
is an empty dictionary. If a value in the dictionary is callable, the
|
|
is an empty dictionary. If a value in the dictionary is callable, the
|
|
view will call it just before rendering the template.
|
|
view will call it just before rendering the template.
|
|
|
|
|
|
- .. 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 1.10.
|
|
|
|
-
|
|
|
|
-``context_instance``
|
|
|
|
- The context instance to render the template with. By default, the template
|
|
|
|
- will be rendered with a ``RequestContext`` instance (filled with values from
|
|
|
|
- ``request`` and ``context``).
|
|
|
|
-
|
|
|
|
- .. deprecated:: 1.8
|
|
|
|
-
|
|
|
|
- The ``context_instance`` argument is deprecated. Simply use ``context``.
|
|
|
|
-
|
|
|
|
``content_type``
|
|
``content_type``
|
|
The MIME type to use for the resulting document. Defaults to the value of
|
|
The MIME type to use for the resulting document. Defaults to the value of
|
|
the :setting:`DEFAULT_CONTENT_TYPE` setting.
|
|
the :setting:`DEFAULT_CONTENT_TYPE` setting.
|
|
@@ -103,7 +88,7 @@ This example is equivalent to::
|
|
``render_to_response``
|
|
``render_to_response``
|
|
======================
|
|
======================
|
|
|
|
|
|
-.. function:: render_to_response(template_name, context=None, context_instance=_context_instance_undefined, content_type=None, status=None, using=None)
|
|
+.. function:: render_to_response(template_name, context=None, content_type=None, status=None, using=None)
|
|
|
|
|
|
Renders a given template with a given context dictionary and returns an
|
|
Renders a given template with a given context dictionary and returns an
|
|
:class:`~django.http.HttpResponse` object with that rendered text.
|
|
:class:`~django.http.HttpResponse` object with that rendered text.
|
|
@@ -125,27 +110,6 @@ Optional arguments
|
|
is an empty dictionary. If a value in the dictionary is callable, the
|
|
is an empty dictionary. If a value in the dictionary is callable, the
|
|
view will call it just before rendering the template.
|
|
view will call it just before rendering the template.
|
|
|
|
|
|
- .. 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 1.10.
|
|
|
|
-
|
|
|
|
-``context_instance``
|
|
|
|
- The context instance to render the template with. By default, the template
|
|
|
|
- will be rendered with a :class:`~django.template.Context` instance (filled
|
|
|
|
- with values from ``context``). If you need to use :ref:`context
|
|
|
|
- processors <subclassing-context-requestcontext>`, render the template with
|
|
|
|
- a :class:`~django.template.RequestContext` instance instead. Your code
|
|
|
|
- might look something like this::
|
|
|
|
-
|
|
|
|
- return render_to_response('my_template.html',
|
|
|
|
- my_context,
|
|
|
|
- context_instance=RequestContext(request))
|
|
|
|
-
|
|
|
|
- .. deprecated:: 1.8
|
|
|
|
-
|
|
|
|
- The ``context_instance`` argument is deprecated. Simply use ``context``.
|
|
|
|
-
|
|
|
|
``content_type``
|
|
``content_type``
|
|
The MIME type to use for the resulting document. Defaults to the value of
|
|
The MIME type to use for the resulting document. Defaults to the value of
|
|
the :setting:`DEFAULT_CONTENT_TYPE` setting.
|
|
the :setting:`DEFAULT_CONTENT_TYPE` setting.
|