[Fixed]-Django delete files from a directory not working

1👍

I see in your file path error, a combination of slash and backslash.
replace ‘/’ to ‘\’ if your application run on windows system.

path = settings.MEDIA_ROOT
os.remove(os.path.join(path, file_name.replace('/', '\')))

Leave a comment