CSV出力
とりあえず写経していじった。写経元はこちら。
# -*- coding: utf-8 -*- from django.http import HttpResponse import csv def getcsv(request): response = HttpResponse(mimetype='text/csv') response['Content-Disposition'] = 'attachment; filename=somefilename.csv' writer = csv.writer(response) writer.writerow(['First row', 'Foo', 'Bar', 'Baz']) writer.writerow(['Second row', 'A', 'B', 'C', '"Testing"', "Here's a quote"]) return response