Django: Redirect after HttpResponse
I am generating a report download in a view and starting the download after processing the POST data. That means the user sends a form and the download starts:
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
What I need is a page refresh after the download (or a redirect). How can I achieve this?
user clicks the link
and comes to /file_downloaded/ where the download starts and after 3 seconds, you just redirect the page via js
to detect if the download is ready is not easy