From 733178830072caeca3c054a220808b4c557faec4 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sat, 22 Nov 2014 09:22:38 +0100 Subject: Avoided rewrapping Contexts in render_to_response. This change preserves backwards-compatibility for a very common misuse of render_to_response which even occurred in the official documentation. It fixes that misuse wherever it happened in the code base and docs. Context.__init__ is documented as accepting a dict and nothing else. Since Context is dict-like, Context(Context({})) could work to some extent. However, things get complicated with RequestContext and that gets in the way of refactoring the template engine. This is the real rationale for this change. --- docs/topics/i18n/translation.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/topics/i18n/translation.txt b/docs/topics/i18n/translation.txt index 8ef9b89c6b..daf66d332b 100644 --- a/docs/topics/i18n/translation.txt +++ b/docs/topics/i18n/translation.txt @@ -860,9 +860,8 @@ If you do this in your view: .. code-block:: python - return render_to_response('mytemplate.html', { - 'available_languages': ['en', 'es', 'fr'], - }, RequestContext(request)) + context = {'available_languages': ['en', 'es', 'fr']} + return render(request, 'mytemplate.html', context) you can iterate over those languages in the template:: -- cgit v1.3