How do i use Django and UTF-8 content-type for tem

2019-07-10 03:49发布

问题:

When I do:

return render_to_response()

in Django. How do I set the content-type to UTF-8? So that everything displayed is UTF-8?

回答1:

django use UTF-8 as default encoding, but this can be modified with settings.DEFAULT_CHARSET.

Be sure, in your HTML template, to set UTF-8 for the HTML page also :

<meta http-equiv="Content-type" content="text/html; charset=utf-8" />