I am following the Django doc here to create a CSV file. In my urls.py I have
response = HttpResponse(mimetype='text/csv')
response['Content-Disposition'] = 'attachment; filename="reports.csv"'
writer = csv.writer(response)
writer.writerow(['First row', 'Foo', 'Bar', 'Baz'])
writer.writerow(['Second row', 'A', 'B', 'C', '"Testing"', "Here's a quote"])
You can't make the browser download a file through AJAX (that's what jQuery is doing when you use
$.get). You have to make a direct synchronous HTTP connection.
$.get, try this:
Related: Force download through js or query