[Answer]-How names files by their hash value?

1👍

You can access the instance field that contains an instance of UploadFile and you can read the contents:

import hashlib

def get_upload_file_name(instance, filename):
    return hashlib.sha1(instance.field.read()).hexdigest()

Leave a comment