📜  django 中的唯一文件名 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:01.154000             🧑  作者: Mango

代码示例1
from django.contrib.auth.models import User
def create_filepath(directory, instance, filename):
    new_filename = "%s.%s" % (User.objects.make_random_password(10),filename.split('.')[-1])
    return '/'.join([directory, new_filename])