django view返回中文名称文件

def shujubiao(request):
    contact_id=request.GET["id"]
    c=Contact.objects.get(id=contact_id)
    fullfilepath = os.path.join(MEDIA_ROOT,"t_证书数据表.xml")
    logging.info(fullfilepath)
    data=genShujubiao(c,fullfilepath)
    t=HttpResponse(data,content_type="text/xml")#application/application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")#content_type="text/xml")#application/vnd.ms-excel")
    tstr='attachment; filename=%s' % c.yonghu+"_"+c.yiqixinghao+"_证书数据表.xml"
    t['Content-Disposition'] = tstr.encode("gb2312")
    return t

猜你喜欢

转载自blog.csdn.net/mahongquan/article/details/49175777