Django: Redirect after HttpResponse -
i generating report download in view , starting download after processing post data. means user sends form , download starts:
views.py
def export(request): if request.method == 'post' , '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
what need page refresh after download (or redirect). how can achieve this?
i in simple logic javascript:
user clicks link
/download_file_now/
and comes /file_downloaded/
download starts , after 3 seconds, redirect page via js
location.replace('/another_url/');
to detect if download ready not easy
Comments
Post a Comment