就是界面上有个按钮,然后点击之后,后台会生成一个文件,比如log文件,然后当生成完成,就可以下载了。
由于第一次处理这种实时文件生成,不太明白怎么实现。谢谢
ringa_lee2017-04-18 10:32:50
Return a downloadable file. As long as you add Content-Disposition=attachment; filename="anyfilename.xxx" in the header of the returned HTTP response, the browser will pop up a download dialog box to prompt the user to download.
The file content background is the same whether it is read from a local file or a string produced by a program. It is stuffed into the HttpResponse object and returned in the corresponding view. Be careful not to keep users waiting for too long.
For an official example of generating a csv file, please refer to: https://docs.djangoproject.co...