在django编程过程中总是会遇到提交表格和跳转的界面,但是在调试过程中偶尔会遇到无法利用绝对路径来给定目标网址,无论写的是什么都会在当前域名下继续添加你的内容,最终结果就是找不到目标网址而报错
<html>
<head>
<title>{{Search}}</title>
</head>
<body>
{%if warnings%}
<p style="color:red;">{{warnings}}</p>
{%endif%}
<center>next is form</center>
<form action="/data_record/contact/" method="get">
<p>Subject<input type="text" name="subject"></p>
<p>your email(optional)<input type="text" name="email"></p>
<p>messages<input type="text" name="message"></p>
<input type="submit" value="Search">
</form>
</body>
</html>
这是网页的样子
本来设计的是通过点击search会自动跳转到目标的127.0.0.1:8000/data_record/contact/界面,但是总是报错,报错界面找不到了,用报错代码代替。在跳转部分的代码带上/就代表是绝对路径,不带/则表示是相对路径,比如/data_record相当于127.0.0.1:8000/data_record。而data_record则表示在项目的url中匹配之后新增加的部分,比如在项目的url中定义path(“data_record/”,include(“data_record.urls”)),此时表示的路径就是127.0.0.1:8000/data_record/data_record/
后来通过重启发现又正常了,mark一下,毕竟debug的过程总是很痛苦的,有时更改的参数反复检查没问题可以尝试重启一下。