I have a model that allow me to upload a file, but for some reason the whitespace defined in the custom upload_to function get replaced by underscore in the file system(or in s3) for both the filename and the folder path.
Is there a way to enforce the use of whitespace?
eg: The file "hello world.png" become "hello_world.png"
ps: I know this is a bad practice to use whitespace, but it's not my choice .
Here is the code:
models.py
one_file = models.FileField(
_('My label'),
null=True,
blank=True,
upload_to=one_file_name,
max_length=500,
#part for s3, using the local media doens't change anything
storage=PrivateMediaStorage(),
)
my upload_to function
def one_file_name(instance, filename):
extension = filename.split(".")[-1]
return f'folder name/subfolder name/{filename}.{extension}'