False commit | Django
my code is working perfectly but I'd like to make some changes and NOT save anymore the uploaded filename in SQLite database.
My code:
# false commit to get upload file name
upload = form.save(commit=False)
upload.save()
uploadFile = upload.file.name.split('/')[-1]
As I said, I don't need right now to save this form in database. I tried to comment out the line upload.save() but the code is not working, displaying the error message below:
Exception Type: com_error
Exception Value: it's possible that the file may be removed, renamed or trashed.
Thank you!
if you just want the uploaded filename in your view then you can get it from request object directly like below:-
for filename, file in request.FILES.iteritems():
name = request.FILES[filename].name