A beginner Django guy here, I am looking to change my csv export file name to be dynamic hopefully naming the file with the date it was generated.

My current code is

response['Content-Disposition'] = 'attachment;filename="export.csv"'

If you could help me out that would be awesome :)

link|improve this question
feedback

1 Answer

from datetime import datetime

...
now = datetime.now()
response['Content-Disposition'] = 'attachment;filename="%s.csv"' % \
    now.strftime('%Y-%m-%d')
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.