django 实现下载功能

from django.http import FileResponse
def download(request):
    if.....
        file=open([path],'rb')
        response=FileResponse(file)
        response['Content-Type'] = 'application/octet-stream'
        response['Content-Disposition'] = 'attachment;filename="[filename].xls"'
  return response
原文地址:https://www.cnblogs.com/wang666/p/9214551.html