diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-01-08 15:03:43 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-01-12 21:01:34 +0100 |
| commit | a3e783fe11dd25bbf84bfb6201186566ed473506 (patch) | |
| tree | 1fe6a54ab582e54f6b1f065f2236bfe2185ce254 /docs | |
| parent | 71b7668b75d10589bbbdc7c5ca9ee7a125f91c90 (diff) | |
Deprecated passing a Context to a generic Template.render.
A deprecation path is required because the return type of
django.template.loader.get_template changed during the
multiple template engines refactor.
test_csrf_token_in_404 was incorrect: it tested the case when the
hardcoded template was rendered, and that template doesn't depend on the
CSRF token. This commit makes it test the case when a custom template is
rendered.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/internals/deprecation.txt | 6 | ||||
| -rw-r--r-- | docs/ref/templates/upgrading.txt | 2 | ||||
| -rw-r--r-- | docs/releases/1.8.txt | 17 |
3 files changed, 25 insertions, 0 deletions
diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt index fe392cff97..e9161e7254 100644 --- a/docs/internals/deprecation.txt +++ b/docs/internals/deprecation.txt @@ -108,6 +108,12 @@ details on these changes. * The backwards compatibility alias ``django.template.loader.BaseLoader`` will be removed. +* Django template objects returned by + :func:`~django.template.loader.get_template` and + :func:`~django.template.loader.select_template` won't accept a + :class:`~django.template.Context` in their + :meth:`~django.template.backends.base.Template.render()` method anymore. + * The ``current_app`` parameter for the following function and classes will be removed: diff --git a/docs/ref/templates/upgrading.txt b/docs/ref/templates/upgrading.txt index ca336e016d..c7b07464b0 100644 --- a/docs/ref/templates/upgrading.txt +++ b/docs/ref/templates/upgrading.txt @@ -95,6 +95,8 @@ entire :setting:`TEMPLATES` setting instead. :mod:`django.template.loader` ============================= +.. _get_template-upgrade-django-18: + :func:`~django.template.loader.get_template` and :func:`~django.template.loader.select_template` ------------------------------------------------------------------------------------------------ diff --git a/docs/releases/1.8.txt b/docs/releases/1.8.txt index 122064971c..4c3b398cd1 100644 --- a/docs/releases/1.8.txt +++ b/docs/releases/1.8.txt @@ -1380,6 +1380,23 @@ to construct the "view on site" URL. This URL is now accessible using the sure to provide a default value for the ``form_class`` argument since it's now optional. +Rendering templates loaded by :func:`~django.template.loader.get_template()` with a :class:`~django.template.Context` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The return type of :func:`~django.template.loader.get_template()` has changed +in Django 1.8: instead of a :class:`django.template.Template`, it returns a +``Template`` instance whose exact type depends on which backend loaded it. + +Both classes provide a ``render()`` method, however, the former takes a +:class:`django.template.Context` as an argument while the latter expects a +:class:`dict`. This change is enforced through a deprecation path for Django +templates. + +Since it's easier to understand with examples, the :ref:`upgrade guide +<get_template-upgrade-django-18>` shows how to adapt affected code. + +All this also applies to :func:`~django.template.loader.select_template()`. + ``current_app`` argument of template-related APIs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
