Skip to content
Snippets Groups Projects
Commit d2e01a46 authored by sandeepsajan0's avatar sandeepsajan0
Browse files

feat: Add timestamp to every new uploaded files

parent 999c1f25
No related branches found
No related tags found
No related merge requests found
from datetime import datetime
from django.core.files import File from django.core.files import File
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django_file_form.models import PlaceholderUploadedFile from django_file_form.models import PlaceholderUploadedFile
...@@ -56,6 +58,7 @@ class AccessFormData: ...@@ -56,6 +58,7 @@ class AccessFormData:
if isinstance(file, cls.stream_file_class): if isinstance(file, cls.stream_file_class):
return file return file
if isinstance(file, File): if isinstance(file, File):
file.name = datetime.now().strftime("%y%m%d") + "-" + file.name
return cls.stream_file_class(instance, field, file, name=file.name, storage=cls.storage_class()) return cls.stream_file_class(instance, field, file, name=file.name, storage=cls.storage_class())
if isinstance(file, PlaceholderUploadedFile): if isinstance(file, PlaceholderUploadedFile):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment