mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
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.
This commit is contained in:
@@ -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
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
Reference in New Issue
Block a user