summaryrefslogtreecommitdiff
path: root/django/shortcuts.py
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2015-01-26 21:57:10 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2015-02-03 08:29:45 +0100
commit2133f3157eff853329bafb7fda74c3c8fb4eae42 (patch)
tree5bb262ab847c79b3f70d8a8888e267b2816b0373 /django/shortcuts.py
parenta53541852d5601232899e54d66e623bc163c6dc2 (diff)
Fixed #24168 -- Allowed selecting a template engine in a few APIs.
Specifically in rendering shortcuts, template responses, and class-based views that return template responses. Also added a test for render_to_response(status=...) which was missing from fdbfc980. Thanks Tim and Carl for the review.
Diffstat (limited to 'django/shortcuts.py')
-rw-r--r--django/shortcuts.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/django/shortcuts.py b/django/shortcuts.py
index 3bb2412526..bbfc99299f 100644
--- a/django/shortcuts.py
+++ b/django/shortcuts.py
@@ -25,7 +25,7 @@ from django.utils.functional import Promise
def render_to_response(template_name, context=None,
context_instance=_context_instance_undefined,
content_type=None, status=None, dirs=_dirs_undefined,
- dictionary=_dictionary_undefined):
+ dictionary=_dictionary_undefined, using=None):
"""
Returns a HttpResponse whose content is filled with the result of calling
django.template.loader.render_to_string() with the passed arguments.
@@ -34,12 +34,13 @@ def render_to_response(template_name, context=None,
and dirs is _dirs_undefined
and dictionary is _dictionary_undefined):
# No deprecated arguments were passed - use the new code path
- content = loader.render_to_string(template_name, context)
+ content = loader.render_to_string(template_name, context, using=using)
else:
# Some deprecated arguments were passed - use the legacy code path
content = loader.render_to_string(
- template_name, context, context_instance, dirs, dictionary)
+ template_name, context, context_instance, dirs, dictionary,
+ using=using)
return HttpResponse(content, content_type, status)
@@ -47,7 +48,8 @@ def render_to_response(template_name, context=None,
def render(request, template_name, context=None,
context_instance=_context_instance_undefined,
content_type=None, status=None, current_app=_current_app_undefined,
- dirs=_dirs_undefined, dictionary=_dictionary_undefined):
+ dirs=_dirs_undefined, dictionary=_dictionary_undefined,
+ using=None):
"""
Returns a HttpResponse whose content is filled with the result of calling
django.template.loader.render_to_string() with the passed arguments.
@@ -59,7 +61,8 @@ def render(request, template_name, context=None,
and dictionary is _dictionary_undefined):
# No deprecated arguments were passed - use the new code path
# In Django 2.0, request should become a positional argument.
- content = loader.render_to_string(template_name, context, request=request)
+ content = loader.render_to_string(
+ template_name, context, request=request, using=using)
else:
# Some deprecated arguments were passed - use the legacy code path
@@ -80,7 +83,8 @@ def render(request, template_name, context=None,
context_instance._current_app = current_app
content = loader.render_to_string(
- template_name, context, context_instance, dirs, dictionary)
+ template_name, context, context_instance, dirs, dictionary,
+ using=using)
return HttpResponse(content, content_type, status)