[Answered ]-Django downloading a csv file with variable in name

2👍

You messed up your ' and ":

response['Content-Disposition'] = 'attachment; filename="results'+str(date)+'.csv"'

This will work. I would suggest this though:

response['Content-Disposition'] = 'attachment; filename="results{}.csv"'.format(str(date))

Also consider using strftime.

👤Euphe

Leave a comment