From fc567443716c64be305f6e1f151606c93f89acc1 Mon Sep 17 00:00:00 2001 From: eric Date: Wed, 28 Sep 2016 18:40:57 -0400 Subject: [PATCH] FileWrapper not needed, is broken --- questionnaire/views.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/questionnaire/views.py b/questionnaire/views.py index 806556c2..5bb87340 100644 --- a/questionnaire/views.py +++ b/questionnaire/views.py @@ -834,7 +834,6 @@ def export_csv(request, qid): # questionnaire_id answers for all subjects. """ import tempfile, csv, cStringIO, codecs - from django.core.servers.basehttp import FileWrapper class UnicodeWriter: """ @@ -878,11 +877,11 @@ def export_csv(request, qid): # questionnaire_id row = ["%s/%s" % (subject.id, subject.state), runid] + [ a if a else '--' for a in answer_row] writer.writerow(row) + fd.seek(0) - response = HttpResponse(FileWrapper(fd), content_type="text/csv") + response = HttpResponse(fd, content_type="text/csv") response['Content-Length'] = fd.tell() response['Content-Disposition'] = 'attachment; filename="export-%s.csv"' % qid - fd.seek(0) return response