summaryrefslogtreecommitdiff
path: root/django/template
diff options
context:
space:
mode:
authorUnai Zalakain <unai@gisa-elkartea.org>2013-11-16 18:54:12 +0100
committerTim Graham <timograham@gmail.com>2014-08-19 17:34:38 -0400
commit5f2542f12a90cfcfb7be776424ef2f7b200df006 (patch)
tree74e78ce1ed7c67e1eb009fcdf8de8e9596361537 /django/template
parent9d6551204eff9d1ab70b67578f99630716df7490 (diff)
Fixed #10190 -- Made HttpResponse charset customizable.
Thanks to Simon Charette, Aymeric Augustin, and Tim Graham for reviews and contributions.
Diffstat (limited to 'django/template')
-rw-r--r--django/template/response.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/django/template/response.py b/django/template/response.py
index f673c5f46a..f65c3adb8b 100644
--- a/django/template/response.py
+++ b/django/template/response.py
@@ -10,7 +10,8 @@ class ContentNotRenderedError(Exception):
class SimpleTemplateResponse(HttpResponse):
rendering_attrs = ['template_name', 'context_data', '_post_render_callbacks']
- def __init__(self, template, context=None, content_type=None, status=None):
+ def __init__(self, template, context=None, content_type=None, status=None,
+ charset=None):
# It would seem obvious to call these next two members 'template' and
# 'context', but those names are reserved as part of the test Client
# API. To avoid the name collision, we use tricky-to-debug problems
@@ -22,7 +23,7 @@ class SimpleTemplateResponse(HttpResponse):
# content argument doesn't make sense here because it will be replaced
# with rendered template so we always pass empty string in order to
# prevent errors and provide shorter signature.
- super(SimpleTemplateResponse, self).__init__('', content_type, status)
+ super(SimpleTemplateResponse, self).__init__('', content_type, status, charset)
# _is_rendered tracks whether the template and context has been baked
# into a final response.
@@ -136,7 +137,7 @@ class TemplateResponse(SimpleTemplateResponse):
rendering_attrs = SimpleTemplateResponse.rendering_attrs + ['_request', '_current_app']
def __init__(self, request, template, context=None, content_type=None,
- status=None, current_app=None):
+ status=None, current_app=None, charset=None):
# self.request gets over-written by django.test.client.Client - and
# unlike context_data and template_name the _request should not
# be considered part of the public API.
@@ -145,7 +146,7 @@ class TemplateResponse(SimpleTemplateResponse):
# having to avoid needing to create the RequestContext directly
self._current_app = current_app
super(TemplateResponse, self).__init__(
- template, context, content_type, status)
+ template, context, content_type, status, charset)
def resolve_context(self, context):
"""Convert context data into a full RequestContext object