質問

こんにちは私は、利用可能な私のコンテンツの平文バージョンを持っていると思います。私はそのための別のテンプレートを持っているので。私はrender_to_responsemimetype="text/plain"を呼び出していますが、私は、コンテンツというHTTP応答でそのページを開くと、ブラウザに伝えたいことは、UTF-8でエンコードされています。私はそれを行うにはどうすればよい(例えば私がrender_to_responseに追加する必要があります)?

役に立ちましたか?

解決

ただ、このようにMIMEタイプに文字セットを追加します:

mimetype="text/html; charset=utf-8"
<時間> 本当にシーンの後ろに何が起こる MIMEタイプがrender_to_responseでkwargsからの取り出しされていることである。

httpresponse_kwargs = {'mimetype': kwargs.pop('mimetype', None)}
return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)

HttpResponseとして設定content_typeに送信

if mimetype:
    content_type = mimetype     # For backwards compatibility
if not content_type:
    content_type = "%s; charset=%s" % (settings.DEFAULT_CONTENT_TYPE,
                settings.DEFAULT_CHARSET)
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top