4

我有一个将数据提交到数据库的 django 表单。成功填写表单并提交数据后,表单将重定向到另一个页面。但是,当用户点击浏览器上的后退按钮时,数据会返回。

有没有办法防止数据返回?

4

1 回答 1

5

将此添加到您的 HTML 中,它不会缓存:

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate, post-check=0, pre-check=0" /> 
<meta http-equiv="Pragma" content="no-cache" />

如果你想要一个 Django 特定的答案。试试这个,虽然结果应该是一样的:

response = HttpResponse()  # Created a HttpResponse
response['Cache-Control'] = 'no-cache'  # Set Cache-Control Header
于 2012-08-07T18:05:25.510 回答