【发布时间】:2018-08-22 10:52:13
【问题描述】:
我有一个在 django 中下载 excel 文件的功能:
x= Y.objects.filter(pk__in=ids)
response = HttpResponse(content_type='application/vnd.ms-excel')
response['Content-Disposition'] = 'attachment; filename=Test.xlsx'
test_data= WriteFile(x)
response.write(test_data)
return response
我的目标是在此之后显示一条消息:
messages.success(request, 'Success!')
但我需要在return response 之后重定向,因为如果不是,则消息不会出现,并且只有在我手动刷新页面时才会出现。
任何想法如何在下载带有return response 的文件后显示该消息?
【问题讨论】:
标签: python django httpresponse