def getfiles(request):
    filenames = ['/tmp/file1.txt', '/tmp/file2.txt']
zip_subdir = 'somefiles'
zip_filename = '%s.zip' % zip_subdir
s = StringIO.StringIO()
zf = zipfile.ZipFile(s, 'w')
for fpath in filenames:
    fdir, fname = os.path.split(fpath)
zip_path = os.path.join(zip_subdir, fname)
zf.write(fpath, zip_path)
zf.close()
resp = HttpResponse(s.getvalue(), mimetype='application/x-zip-compressed')
resp['Content-Disposition'] = 'attachment; filename=%s' % zip_filename
return resp
Django - Create A Zip of Multiple Files and Make It Downloadable