title: How to save an excel file and attach it to new object?
body: <p>I have a django project and I've created an excel file using xlwt(end snippet of file generation).</p>
  
  <pre><code>export_wb.save(output)
  output.seek(0)
  response = HttpResponse(output.getvalue())
  response['Content-Type'] = 'application/vnd.ms-excel'
  response['Content-Disposition'] = 'attachment; filename='+filename
  return response
  </code></pre>
  
  <p>Now in my view I want to generate this file and attach it to a new object and save it, so I have a new object in the admin with an attached excel file. I'm trying something like this</p>
  
  <pre><code>def test(request):
      exported_ingredients = export(request, app_name='ingredients', model_name='ingredient')
      new_export = IngredientExportItem(file_name="x", slug="x", file=exported_ingredients)
      new_export.save()
      return HttpResponseRedirect('/')
  </code></pre>
  
  <p>I keep getting this error though: <code>'HttpResponse' object has no attribute '_committed'</code></p>
  
  <p>Doesn't seem to like the object I'm setting to 'file' property(file is a fileupload field). If I just return the object then my browser downloads the file correctly so the file is OK.</p>