Django - ZipFile to response not working in python 2.7.9

Django - ZipFile to response not working in python 2.7.9

Postby unicorn » Tue Aug 23, 2016 6:15 am

Hello. Has anybody come across with the issue that the ZipFile(response, 'w') is not working with python 2.7.9? The same code works with python 2.7.0 and 2.7.6 and it's frustrating!

Code: Select all
from django.http import HttpResponse
...
response = HttpResponse(content_type='application/zip')
response['Content-Disposition'] = 'attachment; filename="file.zip"'

with ZipFile(response, 'w') as output:
    output.writestr('output.txt', 'data to write')

return response

Code: Select all
AttributeError: 'HttpResponse' object has no attribute 'seek'
Last edited by Yoriz on Tue Aug 23, 2016 6:19 am, edited 1 time in total.
Reason: First post lock.
unicorn
 
Posts: 1
Joined: Tue Aug 23, 2016 6:13 am

Return to Web Development

Who is online

Users browsing this forum: No registered users and 2 guests

cron