3
我有這樣的代碼:的Django的視圖生成CSV文件,並下載
with open('stockitems_misuper.csv', 'wb') as myfile:
wr = csv.writer(myfile, quoting=csv.QUOTE_ALL)
wr.writerows(file_rows)
response = HttpResponse(myfile, content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename=stockitems_misuper.csv'
return response
我得到的錯誤:
I/O operation on closed file
我怎樣才能創建的CSV文件發送到前端?