mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 17:47:04 +03:00
parent
b0ba8d61ec
commit
7ae8409370
|
@ -193,6 +193,7 @@ class YAMLRenderer(BaseRenderer):
|
|||
format = 'yaml'
|
||||
encoder = encoders.SafeDumper
|
||||
charset = 'utf-8'
|
||||
ensure_ascii = True
|
||||
|
||||
def render(self, data, accepted_media_type=None, renderer_context=None):
|
||||
"""
|
||||
|
@ -203,7 +204,15 @@ class YAMLRenderer(BaseRenderer):
|
|||
if data is None:
|
||||
return ''
|
||||
|
||||
return yaml.dump(data, stream=None, encoding=self.charset, Dumper=self.encoder)
|
||||
return yaml.dump(data, stream=None, encoding=self.charset, Dumper=self.encoder, allow_unicode=not self.ensure_ascii)
|
||||
|
||||
|
||||
class UnicodeYAMLRenderer(YAMLRenderer):
|
||||
"""
|
||||
Renderer which serializes to YAML.
|
||||
Does *not* apply character escaping for non-ascii characters.
|
||||
"""
|
||||
ensure_ascii = False
|
||||
|
||||
|
||||
class TemplateHTMLRenderer(BaseRenderer):
|
||||
|
|
Loading…
Reference in New Issue
Block a user