title: Python/Django: Offering a zip file for download from io.BytesIO buffer
body: <p>I'm trying to put a zip file into an io.BytesIO buffer and then offer that for download. Below is what I've got (part of a longer views.py, I'm just posting the relevant part). </p>
  
  <p><em>But I'm getting the following error message:</em></p>
  
  <pre><code>AttributeError at 'bytes' object has no attribute 'read'
  </code></pre>
  
  <p><strong>Can anyone tell me what I'm doing wrong?</strong></p>
  
  <pre><code>from django.http import HttpResponse
  from wsgiref.util import FileWrapper
  from zipfile import *
  import io
  
  buffer = io.BytesIO()
  
  zipf = ZipFile(buffer, "w")
  zipf.write ("file.txt")
  zipf.close()
  
  response = HttpResponse(FileWrapper(buffer.getvalue()), content_type='application/zip')
  response['Content-Disposition'] = 'attachment; filename=file.zip'
  
  return response
  </code></pre>
  
  <p><strong><em>Edit:</strong> It's telling me the error is coming from the line:<br></em></p>
  
  <pre><code>response = HttpResponse(FileWrapper(buffer.getvalue()), content_type='application/zip')
  </code></pre>