title: Is there a better way to handle AJAX file downloads with Django?
body: <p>I am pretty new to web development in general; I am kind of learning everything on the fly. I recently got a Django application up and running, but I feel pretty dirty/hacky the way I did things.</p>
  
  <p><strong>Problem:</strong> User needs to input (potentially) a lot of data into an Excel-like spreadsheet on my webpage. I currently am using Handsontable for this. I then need to take the data, run some queries on it, process the results, and return an Excel sheet to the user. </p>
  
  <p>Since the Handsontable is rendered via Javascript on page load, and not by Django, I needed to figure out a work around for getting the data into my views.py (I also couldn't strictly use AJAX because I could not figure out how to send the file to the browser once the request was completed).</p>
  
  <p><strong>Current solution:</strong> I have a Django Textarea hidden. When the user submits the form, I have a Javascript function dump the Handsontable into it in JSON form. Then in my views.py I parse the JSON, and do what I need to do with it, and return the Excel file to the user. Having a hidden field to get around all of this just doesn't seem right.</p>
  
  <p>Is there a better way to send Django information and still have it handle the response? Like I said above, using AJAX worked great until the very end - when I had to serve the file to the user <em>without</em> having them click an extra link (or other work-arounds I've seen).</p>