summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorBaptiste Mispelon <bmispelon@gmail.com>2014-02-22 22:28:27 +0100
committerBaptiste Mispelon <bmispelon@gmail.com>2014-02-22 23:33:48 +0100
commit7e1376c2b0ea9e02e61c1c764f02cd40c6f7e849 (patch)
tree982d36e199720e862edb1403239bf3be313715be /django
parent1d3ae4760b060f0df2965a2cfbee941bf8da6b31 (diff)
Fixed #21741 -- Fixed render_to_string to stop pushing empty dictionaries to its Context
Thanks to kezabelle for the report and original patch and to numerodix for his improved patch.
Diffstat (limited to 'django')
-rw-r--r--django/template/loader.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/django/template/loader.py b/django/template/loader.py
index e9e2172e4b..036921f2f4 100644
--- a/django/template/loader.py
+++ b/django/template/loader.py
@@ -164,13 +164,14 @@ def render_to_string(template_name, dictionary=None, context_instance=None,
get_template, or it may be a tuple to use select_template to find one of
the templates in the list. Returns a string.
"""
- dictionary = dictionary or {}
if isinstance(template_name, (list, tuple)):
t = select_template(template_name, dirs)
else:
t = get_template(template_name, dirs)
if not context_instance:
return t.render(Context(dictionary))
+ if not dictionary:
+ return t.render(context_instance)
# Add the dictionary to the context stack, ensuring it gets removed again
# to keep the context_instance in the same state it started in.
with context_instance.push(dictionary):