Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 :)

share|improve this question

closed as off topic by EEAA, Shane Madden, voretaq7 Jul 27 '12 at 16:27

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

1 Answer

from datetime import datetime

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

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