[Solved]-How to get uploaded file name in django

15๐Ÿ‘

โœ…

As far as I know, the filename is stored in the name attribute of the model field, in your case

newfile.uploadfile.name

and the path of the file is stored in

newfile.uploadfile.path

Please see the official Django docs for further reference, as well as many other SO Q&A (e.g. this one)

In case you want to adopt your own format for the file name you can specify a callable in the upload_to parameter of the model field, as explained here

๐Ÿ‘คPynchia

Leave a comment