Django删除然后重定向

我有一种情况,我不知道如何用Django解决。用户正在处理表单,然后一旦表单完成,用户便可以从表单中的数据生成PDF。我想将用户重定向到另一个页面,因为一旦生成了文档,就无需在表单页面中说了。

views.py

response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = "attachment; filename=" + filename +'.pdf'
response.write(pdf)

return response
tianlong253 回答:Django删除然后重定向

您可以使用redirect内置的Django在视图函数中进行重定向:

from django.http import HttpResponseRedirect

response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = "attachment; filename=" + filename +'.pdf'
response.write(pdf)

return HttpResponseRedirect("/some-url")
本文链接:https://www.f2er.com/3162961.html

大家都在问