擅长:python、mysql、java
<p>在响应中发送文件附件是<a href="http://docs.djangoproject.com/en/dev/ref/request-response/#telling-the-browser-to-treat-the-response-as-a-file-attachment" rel="nofollow">covered in the documentation</a>。</p>
<p>有两件事你的案子医生没有提到:</p>
<ol>
<li>您需要将文件数据作为第一个参数传递给<code>HttpResponse()</code>(<code>my_data</code>,在本例中)。</li>
<li>您需要正确的mimetype(<code>application/zip</code>)。</li>
</ol>