我想使用Django views. 我在堆栈溢出中经历了许多解决方案。但是该文件根本没有被下载。这是我正在使用的代码。
谁能告诉我哪里出错了。
response = HttpResponse(mimetype='application/zip')
response['Content-Disposition'] = 'attachment; filename=%s' % doc[Zip_file_name]
response['X-Sendfile'] = "./Zipfiles" # the path where the zip files are stored
return response
在chrome, 如果我使用inspect element, 并双击选项卡中url显示network的文件,文件将被下载,因为它被识别为http获取请求,而button click没有任何反应。
请帮忙。