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:
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
What I need is a page refresh after the download (or a redirect). How can I achieve this?
I would just do it in simple logic with javascript:
user clicks the link
/download_file_now/
and comes to /file_downloaded/
where the download starts and after 3 seconds, you just redirect the page via js
location.replace('/another_url/');
to detect if the download is ready is not easy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With