【发布时间】:2013-05-18 04:45:14
【问题描述】:
我在 Django 中使用以下视图创建文件并让浏览器下载它
def aux_pizarra(request):
myfile = StringIO.StringIO()
myfile.write("hello")
response = HttpResponse(FileWrapper(myfile), content_type='text/plain')
response['Content-Disposition'] = 'attachment; filename=prueba.txt'
return response
但是下载的文件总是空白的。
有什么想法吗? 谢谢
【问题讨论】:
标签: python django web-applications django-views