You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6 lines
286 B

6 months ago
from django.utils import timezone
def rename_profile_image(instance, filename):
current_time = timezone.now().strftime('%Y%m%d%H%M%S')
ext = filename.split('.')[-1]
new_filename = f"profiles/{timezone.now().strftime('%Y/%m/%d')}/{current_time}.{ext}"
return new_filename