aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/response.py
diff options
context:
space:
mode:
authorKarol Majta2013-05-18 16:45:05 +0200
committerKarol Majta2013-05-18 16:45:05 +0200
commitebe959b52a10a88975b15c69275b0ef5c50cb9fa (patch)
treed54eab80e5238b1b6312cdd3916a1f90522ab8c4 /rest_framework/response.py
parentb950b025bc66e3018d5f74e1494ff17f7742be75 (diff)
downloaddjango-rest-framework-ebe959b52a10a88975b15c69275b0ef5c50cb9fa.tar.bz2
charset param gets now appended to response's Content-Type. Closes #807
Diffstat (limited to 'rest_framework/response.py')
-rw-r--r--rest_framework/response.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/rest_framework/response.py b/rest_framework/response.py
index 26e4ab37..40372f22 100644
--- a/rest_framework/response.py
+++ b/rest_framework/response.py
@@ -39,14 +39,18 @@ class Response(SimpleTemplateResponse):
def rendered_content(self):
renderer = getattr(self, 'accepted_renderer', None)
media_type = getattr(self, 'accepted_media_type', None)
+ charset = getattr(self, 'charset', None)
context = getattr(self, 'renderer_context', None)
assert renderer, ".accepted_renderer not set on Response"
assert media_type, ".accepted_media_type not set on Response"
assert context, ".renderer_context not set on Response"
context['response'] = self
-
- self['Content-Type'] = media_type
+ if charset is not None:
+ ct = "{0}; charset={1}".format(media_type, charset)
+ else:
+ ct = media_type
+ self['Content-Type'] = ct
return renderer.render(self.data, media_type, context)
@property
@@ -67,4 +71,4 @@ class Response(SimpleTemplateResponse):
for key in ('accepted_renderer', 'renderer_context', 'data'):
if key in state:
del state[key]
- return state
+ return state \ No newline at end of file