My problem is: I need to generate a csv file from the data I have in the database and then download it. Seems easy, but I cannot find a solution that will allow me to do it in the background so the user won't be redirected anywhere. What I need is user clicking a button and the download starting immediately with the user staying on the same page. Something like a simple html download attribute, but with actually generating a file first. I cannot generate file in advance as the data changes all the time and I need to output the most recent version of it, also, user may specify some filters for the data, so I need to take it into account. I use Django with Nginx as a production server. Django should always return a response, so I'm not sure I would be able to do what I want at all. Is there any different way to do it then? I've searched for a long time, but unable to find anything similar to my request. Thanks everyone!
Asked
Active
Viewed 752 times
0
-
Possible duplicate of [Having Django serve downloadable files](https://stackoverflow.com/questions/1156246/having-django-serve-downloadable-files) – vishes_shell Jan 25 '18 at 10:23
-
Thank you! This question was close, but didn't worked for me, maybe I was just looking for more detailed tutorial. However this snippet (https://www.djangosnippets.org/snippets/491/ ) helped me, I find it to be good for beginners (such as myself). Should I post it as an answer or delete my question at all? – Shepherd Jan 26 '18 at 01:43