我正在使用Django框架,但我是新来的。目前,我正在重命名2个上传的文件,但无法弄清楚。这是view.py
中的代码def simple_upload(request):
if request.method == 'POST' and request.FILES['myfile']:
myfile = request.FILES['myfile']
fs = FileSystemStorage()
filename = fs.save(myfile.name, myfile)
uploaded_file_url = fs.url(filename)
return render(request, 'core/simple_upload.html', {
'uploaded_file_url': uploaded_file_url
})
return render(request, 'core/simple_upload.html')
当前,它可以将其上载并存储在媒体中,但是我需要将第一个上载的文件硬编码为“ file1”,将第二个上载的文件硬编码为“ file2”,谢谢您的帮助