0
xsl
ファイルのコンテンツタイプを設定しようとしています。これは、これまでのところ、私がやっていること Django Content-Type for text/xsl
def xsl_content_type():
filename = static('sitemap.xsl')
response = HttpResponse(filename)
response['Content-Type'] = "text/xsl"
response['Content-Length'] = len(filename)
return response
である。これは
HTTP/1.0 200 OK
Date: Wed, 13 Sep 2017 05:04:46 GMT
Server: WSGIServer/0.2 CPython/3.6.1
Last-Modified: Tue, 13 Jun 2017 03:54:17 GMT
Content-Length: 7134
Content-Type: application/octet-stream
Cache-Control: max-age=0, public
Access-Control-Allow-Origin: *
を返したとしても、私が得るすべてはapplication/octet-stream
で、私はセットアップにtext/xsl
としてContent-Type
をしたと思いました。私もresponse = HttpResponse(filename, content_type="text/xsl")
をやってみましたが、コンテンツタイプは同じです。
私はここで何が欠けていますか? url(r'^sitemap\.xsl', xsl_content_type, name='sitemap_xsl')
次のコードを追加します
views.py
urlpatterns
を追加
こんにちは、このhttps://djangotricks.blogspot.in/2013/12/how-to-export-data-as-excel.htmlをご覧ください – Robert