from django.utils.encoding import escape_uri_path
from django.http import HttpResponse
def download(request):
fn = "中文文件.xlsx" with open(fn, 'rb') as f:
content = f.read()
response = HttpResponse(content) response['Content-Type'] = 'application/octet-stream' response['Content-Disposition'] = 'attachment;filename='{}'.format(escape_uri_path(fn)) return response