Django uploads: Discard uploaded duplicates, use existing file (md5 based check)
问题 I have a model with a FileField , which holds user uploaded files. Since I want to save space, I would like to avoid duplicates. What I'd like to achieve: Calculate the uploaded files md5 checksum Store the file with the file name based on its md5sum If a file with that name is already there (the new file's a duplicate ), discard the uploaded file and use the existing file instead 1 and 2 is already working, but how would I forget about an uploaded duplicate and use the existing file instead?