【发布时间】:2019-12-01 17:38:37
【问题描述】:
我正在使用这种方法将 pandas 数据帧下载为 csv 文件:
view.py ....
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename="' + filename + '"'
my_df.to_csv(response, encoding='utf-8', index=False, )
return response
在我的 html 中,我有 ...
<form class="default_form" method="POST" action="do_export">
{% csrf_token %}
<br/>
<input type="submit" class="btn btn-primary exportOut" value="Do Export"
id="myExport"/>
<br/>
</form>
文件导出工作正常。但是,导出完成后,我需要能够在 html 页面上显示一条消息....类似于 {{ my_message}} 无需重新加载页面。
如果这是可行的,我将不胜感激任何关于如何做到这一点的建议,而不求助于 AJAX,我放弃了 AJAX,因为有些下载可能很大。
【问题讨论】:
标签: django export-to-csv message