django 文档提到 上传文件引入 from somewhere 为啥提示没有库?

请问你的django是最新版本吗?from django.http import HttpResponseRedirectfrom django.shortcuts import renderfrom .forms import UploadFileForm# Imaginary function to handle an uploaded file.from somewhere import handle_uploaded_filedef upload_file(request): if request.method == \u0026#39;POST\u0026#39;: form = UploadFileForm(request.POST, request.FILES) if form.is_valid(): handle_uploaded_file(request.FILES) return HttpResponseRedirect(\u0026#39;/success/url/\u0026#39;) else: form = UploadFileForm() return render(request, \u0026#39;upload.html\u0026#39;, {\u0026#39;form\u0026#39;: form})
■网友
意思是自己在某个定义upload_file(request)这个函数,然后导入进去,如果你在当前窗口定义就不用导入了


    推荐阅读