aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/response.py
diff options
context:
space:
mode:
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