diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/internals/deprecation.txt | 2 | ||||
| -rw-r--r-- | docs/ref/contrib/admin/admindocs.txt | 10 | ||||
| -rw-r--r-- | docs/releases/1.8.txt | 2 | ||||
| -rw-r--r-- | docs/topics/http/shortcuts.txt | 43 |
4 files changed, 42 insertions, 15 deletions
diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt index f703b958a0..0adf08ed5e 100644 --- a/docs/internals/deprecation.txt +++ b/docs/internals/deprecation.txt @@ -93,6 +93,8 @@ details on these changes. * The ``dictionary`` and ``context_instance`` parameters for the following functions will be removed: + * ``django.shortcuts.render()`` + * ``django.shortcuts.render_to_response()`` * ``django.template.loader.render_to_string()`` * The ``dirs`` parameter for the following functions will be removed: diff --git a/docs/ref/contrib/admin/admindocs.txt b/docs/ref/contrib/admin/admindocs.txt index 6e2ca745cf..040dc25fe0 100644 --- a/docs/ref/contrib/admin/admindocs.txt +++ b/docs/ref/contrib/admin/admindocs.txt @@ -95,6 +95,8 @@ you can document in your view function docstrings include: For example:: + from django.shortcuts import render + from myapp.models import MyModel def my_view(request, slug): @@ -103,8 +105,6 @@ For example:: **Context** - ``RequestContext`` - ``mymodel`` An instance of :model:`myapp.MyModel`. @@ -113,10 +113,8 @@ For example:: :template:`myapp/my_template.html` """ - return render_to_response('myapp/my_template.html', { - 'mymodel': MyModel.objects.get(slug=slug) - }, context_instance=RequestContext(request)) - + context = {'mymodel': MyModel.objects.get(slug=slug)} + return render(request, 'myapp/my_template.html', context) Template tags and filters reference =================================== diff --git a/docs/releases/1.8.txt b/docs/releases/1.8.txt index 3e6a95006e..8f871cb96c 100644 --- a/docs/releases/1.8.txt +++ b/docs/releases/1.8.txt @@ -1210,6 +1210,8 @@ now optional. The following functions will no longer accept the ``dictionary`` and ``context_instance`` parameters in Django 2.0: +* ``django.shortcuts.render()`` +* ``django.shortcuts.render_to_response()`` * ``django.template.loader.render_to_string()`` Use the ``context`` parameter instead. When ``dictionary`` is passed as a diff --git a/docs/topics/http/shortcuts.txt b/docs/topics/http/shortcuts.txt index 7a92b690e9..5c356c2b3b 100644 --- a/docs/topics/http/shortcuts.txt +++ b/docs/topics/http/shortcuts.txt @@ -15,7 +15,7 @@ introduce controlled coupling for convenience's sake. ``render`` ========== -.. function:: render(request, template_name[, dictionary][, context_instance][, content_type][, status][, current_app][, dirs]) +.. function:: render(request, template_name[, context][, context_instance][, content_type][, status][, current_app][, dirs]) Combines a given template with a given context dictionary and returns an :class:`~django.http.HttpResponse` object with that rendered text. @@ -41,15 +41,24 @@ Required arguments Optional arguments ------------------ -``dictionary`` +``context`` A dictionary of values to add to the template context. By default, this is an empty dictionary. If a value in the dictionary is callable, the 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 2.0. + ``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 ``dictionary``). + ``request`` and ``context``). + + .. deprecated:: 1.8 + + The ``context_instance`` argument is deprecated. Simply use ``context``. ``content_type`` The MIME type to use for the resulting document. Defaults to the value of @@ -67,7 +76,7 @@ Optional arguments The ``dirs`` parameter was added. -.. versionchanged:: 1.8 +.. deprecated:: 1.8 The ``dirs`` parameter was deprecated. @@ -99,7 +108,7 @@ This example is equivalent to:: ``render_to_response`` ====================== -.. function:: render_to_response(template_name[, dictionary][, context_instance][, content_type][, dirs]) +.. function:: render_to_response(template_name[, context][, context_instance][, content_type][, status][, dirs]) Renders a given template with a given context dictionary and returns an :class:`~django.http.HttpResponse` object with that rendered text. @@ -116,32 +125,48 @@ Required arguments Optional arguments ------------------ -``dictionary`` +``context`` A dictionary of values to add to the template context. By default, this is an empty dictionary. If a value in the dictionary is callable, the 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 2.0. + ``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 ``dictionary``). If you need to use :ref:`context + 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_data_dictionary, + my_context, context_instance=RequestContext(request)) + .. deprecated:: 1.8 + + The ``context_instance`` argument is deprecated. Simply use ``context``. + ``content_type`` The MIME type to use for the resulting document. Defaults to the value of the :setting:`DEFAULT_CONTENT_TYPE` setting. +``status`` + The status code for the response. Defaults to ``200``. + +.. versionchanged:: 1.8 + + The ``status`` parameter was added. + .. versionchanged:: 1.7 The ``dirs`` parameter was added. -.. versionchanged:: 1.8 +.. deprecated:: 1.8 The ``dirs`` parameter was deprecated. |
