Problem Background I am new to django. I am trying to upload the file from client and save it. For this pupose i have created below model.
from django.db import models
class UploadFile(models.Model):
uploadfile = models.FileField(upload_to='toProcess/')
I am using this model as below to save the file.
newfile = UploadFile(uploadfile = request.FILES['file'])
newfile.save()
It is saving file. But now I want to process saved file. In django, if the file with the same name alreday exists then it is adding some unique postfix to the original file name. I am happy with this approch and do not want to write a new method to create a unique filename.
Probelm- How to get the new unique name calculated by django for a file?
Mean If I will upload a same file two times say "abc.pdf" then it will save the first uploaded file as "abc.pdf" and second uploaded file as "abc_somesuffix.pdf". How to know what is the name of saved file?