74297/how-to-change-the-file-name-of-an-uploaded-file-in-django
Is it possible to change the file name of an uploaded file in django?
My requirement is whenever a file is uploaded its file name should be changed in the following format.
format = userid + transaction_uuid + file_extension.
Hello @kartik,
The basic way is
import os os.rename('a.txt', 'b.html')
For your situation, it would probably look like
os.rename ("a.txt", "{id}{uuid}.{ext}".format(id=userid, uuid=transaction_uuid, ext=file_extension))
Hope it works!!
You can get the changing time from ...READ MORE
If you want to find the value ...READ MORE
Hey, Web scraping is a technique to automatically ...READ MORE
Hi, @Roshni, You can use this code below: import ...READ MORE
Hi, there is only that way and ...READ MORE
Hi all, with regard to the above ...READ MORE
Hello @kartik, To turn off foreign key constraint ...READ MORE
Hello @kartik, Let's say you have this important ...READ MORE
Hello @kartik, The easiest way for your use ...READ MORE
Hello @kartik, Inside a manager: def delete_everything(self): ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.