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
posted @ 2018-06-22 17:31  月河  阅读(100)  评论(0编辑  收藏  举报