mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-19 21:11:04 +03:00
Fixed docs' custom render example. (#7171)
This commit is contained in:
parent
a7a362813b
commit
0c8eb91737
|
@ -273,7 +273,7 @@ By default this will include the following keys: `view`, `request`, `response`,
|
||||||
|
|
||||||
The following is an example plaintext renderer that will return a response with the `data` parameter as the content of the response.
|
The following is an example plaintext renderer that will return a response with the `data` parameter as the content of the response.
|
||||||
|
|
||||||
from django.utils.encoding import smart_unicode
|
from django.utils.encoding import smart_text
|
||||||
from rest_framework import renderers
|
from rest_framework import renderers
|
||||||
|
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ The following is an example plaintext renderer that will return a response with
|
||||||
format = 'txt'
|
format = 'txt'
|
||||||
|
|
||||||
def render(self, data, media_type=None, renderer_context=None):
|
def render(self, data, media_type=None, renderer_context=None):
|
||||||
return data.encode(self.charset)
|
return smart_text(data, encoding=self.charset)
|
||||||
|
|
||||||
## Setting the character set
|
## Setting the character set
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user