[英]Redirect to the another html page after clicking input tag in django template
I want to redirect the website after edit ( http://127.0.0.1:8000/account/edit/ ) to the dashboard ( http://127.0.0.1:8000/account/dashboard ) in Django template.我想在编辑( http://127.0.0.1:8000/account/edit/ )后将网站重定向到 Django 模板中的仪表板( http://127.0.0.1:8000/account/dashboard )。 I have a file named dashboard.html in the same directory.我在同一目录中有一个名为dashboard.html 的文件。 But it keeps me to the same page ( http://127.0.0.1:8000/account/edit/ .但它让我停留在同一页面( http://127.0.0.1:8000/account/edit/ 。
edit.html编辑.html
{% extends "base.html" %} {% block title %}Edit your account{% endblock %} {% block content %} <h1>Edit your account</h1> <p>You can edit your account using the following form:</p> <form action="dashboard.html" method="post" enctype="multipart/form-data"> {{ user_form.as_p }} {{ profile_form.as_p }} {% csrf_token %} <p><input type="submit" value="Save change"></p> </form> {% endblock %}
This can be achieved with js (jquery in this example):这可以通过 js 实现(在这个例子中是 jquery):
script.js:脚本.js:
$('#button-id').click(function() {
window.location = 'the_new_url';
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.