0

I am currently returning a response page as a string but I also want to pass it as an excel file. I am having trouble doing both.

This is my views.py file:

response = HttpResponse(htmlString)
response = HttpResponse(mimetype='application/vnd.ms-excel')
response['Content-Disposition'] = 'attachment; filename=example1.xls'
book.save(response)    

return response

This only gives me the excel file and not the HtmlString which is because I am reassigning response but I dont know how to include both paramaters.

THanks in advance!!

4

1 回答 1

1

HTTP 响应(如在 HTTP 协议中,不限于 Django)将被浏览器视为文件或显示在浏览器中(html、纯文本等)。您不能同时返回响应。

于 2012-09-10T22:59:22.617 回答