Django删除然后重定向

Django删除然后重定向,django,Django,我有一个案件,我不知道如何在django解决。用户正在表单中工作,一旦表单完成,用户就可以从表单中的数据生成PDF。我想将用户重定向到另一个页面,因为一旦生成文档,就不需要在表单页面中说明 views.py response = HttpResponse(content_type='application/pdf') response['Content-Disposition'] = "attachment; filename=" + filename +'.pdf' response.writ

我有一个案件,我不知道如何在django解决。用户正在表单中工作,一旦表单完成,用户就可以从表单中的数据生成PDF。我想将用户重定向到另一个页面,因为一旦生成文档,就不需要在表单页面中说明

views.py

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

return response

您可以使用内置的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")