[英]How to prevent browser from refilling form data when navigating back in Django
I have a django form that submits data to a database. 我有一个django表单,将数据提交到数据库。 When the form has been successfully filled out and the data submitted, the form redirects to another page.
表单已成功填写并提交数据后,表单将重定向到另一页。 However, when the user hits the back button on the browser, the data comes back.
但是,当用户点击浏览器上的后退按钮时,数据会恢复。
Is there a way to prevent the data from coming back? 有没有办法阻止数据回来?
Add this to your HTML and it will not cache: 将其添加到您的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" />
If you want a Django specific answer. 如果你想要一个Django特定的答案。 Try this though the result should be same:
尝试这个虽然结果应该是相同的:
response = HttpResponse() # Created a HttpResponse
response['Cache-Control'] = 'no-cache' # Set Cache-Control Header
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.