[Answered ]-How to use curent date in image path django

2👍

Use the datetime.date.strftime() function.

from datetime import date

def get_image_path(self, filename):
     path = ''.join([date.today().strftime('static/article/%Y/%m/%d/'),
                     translit.slugify(filename)])
     return path

0👍

You can return a string from your upload_to function – in this case get_image_path, with the date-formatters in it, and Django will pass the date information to the string. (https://docs.djangoproject.com/en/1.7/ref/models/fields/#django.db.models.FileField.upload_to)

👤vishen

Leave a comment