Excel 下载
前端:
<button onclick="window.location.href='/download_excel'">下载文件</button>
url配置。。。
后台:
with open('D:/project/Python/pachong_project/pachong_project/app/templates/app/test.xls','rb') as f:
result = f.read()
response = HttpResponse(result)
response['Content-Disposition'] = 'attachment; filename=test.xls'
return response