我在视图中生成报告下载并在处理POST数据后开始下载。这意味着用户发送表单并开始下载:
views.py
def export(request):
if request.method == 'POST' and 'export_treat' in request.POST:
form1 = TransExport(request.POST, instance= obj)
if form1.is_valid():
...
...
response=HttpResponse(ds.xls,content_type="application/xls")
response['Content-Disposition'] = 'attachment; filename="Report_Behandlungen.xls"'
return response
我需要的是下载(或重定向)后的页面刷新。 我怎样才能做到这一点?
答案 0 :(得分:1)
我会用简单的逻辑用javascript:
来做用户点击链接
/download_file_now/
来到/file_downloaded/
下载开始,3秒后,您只需通过js重定向页面
location.replace('/another_url/');
检测下载是否准备就绪并不容易