I have a function that download a excel file in django:
x= Y.objects.filter(pk__in=ids)
response = HttpResponse(content_type='application/vnd.ms-excel')
response['Content-Disposition'] = 'attachment; filename=Test.xlsx'
test_data= WriteFile(x)
response.write(test_data)
return response
My objective it's to appear a message after this:
messages.success(request, 'Success!')
But I need to redirect after the return response
because if not the message not appear and only appear if I refresh the page manually.
Any ideas how to make the message appear after download a file with the return response
?