response["Content-Disposition"] = "attachment;filename=文件名"
如果要实现预览效果 (图片、文本文件才支持预览)
response["Content-Disposition"] = "inline;filename=文件名"
response["Content-Type"] = "文件的类型"
response["Content-Length"] = 文件的大小
from django.utils.http import urlquote
response["Content-Disposition"] = "attachment;filename=urlquote(文件名)"
原文:https://www.cnblogs.com/hylone/p/11887733.html