def download(self, request, pk=None):
import qrcode
instance = self.get_object()
response = HttpResponse(content_type='application/zip') # 指明下载的文件格式
response['Content-Disposition'] = 'attachment;filename=QrCode.zip'
with zipfile.ZipFile(response, "w", zipfile.ZIP_DEFLATED) as zip_fp:
for _ in QrCode.objects.filter(business_apply=instance):
img = qrcode.make(SERVER_URL+str(_.uuid))
with zip_fp.open(f"{_.uuid}.png", "w") as f:
img.save(f)
return response



