如何在从django视图下载文件时显示微调器(加载器)

如何在从django视图下载文件时显示微调器(加载器),django,django-views,django-templates,Django,Django Views,Django Templates,在django视图中下载文件之前如何显示微调器/加载器 <button type="submit" class="buttons">Download</button> def some view(request): with fs.open("filename.pdf") as pdf: response = HttpResponse(pdf, content_type=

在django视图中下载文件之前如何显示微调器/加载器

<button type="submit" class="buttons">Download</button>

def some view(request):
        with fs.open("filename.pdf") as pdf:
            response = HttpResponse(pdf, content_type='application/pdf')
            response['Content-Disposition'] = "attachment; filename=filename.pdf"
            return response
下载
定义某些视图(请求):
使用fs.open(“filename.pdf”)作为pdf:
response=HttpResponse(pdf,content\u type='application/pdf')
响应['Content-Disposition']=“附件;文件名=文件名.pdf”
返回响应