NoReverseMatch at /salesman/zhuce/ Reverse for '/zhuce/' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
NoReverseMatch at /salesman/zhuce/
Reverse for '/zhuce/' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
对于上面的错误,有可能是django模板的错误,下面我粘贴出来错误的配置代码
一. 错误代码,错误部门用红色字体标出
错误配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <div id = "user" > <form action = "{% url '/zhuce/' %}" method = "post" enctype = "application/x-www-form-urlencoded" > { % csrf_token % } {{ Register_from.user_name.label }}{{ Register_from.user_name }}<br><br> {{ Register_from.password.label }}{{ Register_from.password }}<br><br> {{ Register_from.phone_no.label }}{{ Register_from.phone_no }}<br>{{ raise_error }}<br> {{ Register_from.email.label }}{{ Register_from.email }}<br><br> {{ Register_from.department.label }}{{ Register_from.department }}<br><br><br><br> < input type = "submit" class = "button small border-radius-bottom coral-bg" style = "width: 50px ;height:30px;" value = "注册" onclick = "loading();" > <br>{{ register_success }}{{ register_fail }} < / form> < / div> |
正确配置
一 用表单生成模板的正确action配置
<body> <div id ="user"> <form action="{% url 'zhuce' %}" method="post" enctype="application/x-www-form-urlencoded"> {% csrf_token %} {{ Register_from.user_name.label }}{{ Register_from.user_name }}<br><br> {{ Register_from.password.label }}{{ Register_from.password }}<br><br> {{ Register_from.phone_no.label }}{{ Register_from.phone_no }}<br>{{ raise_error }}<br> {{ Register_from.email.label }}{{ Register_from.email }}<br><br> {{ Register_from.department.label }}{{ Register_from.department }}<br><br><br><br> <input type="submit" class="button small border-radius-bottom coral-bg" style="width: 50px ;height:30px;" value="注册" onclick="loading();" > <br>{{ register_success }}{{ register_fail }} </form> </div>
二.用HTML写的前段 action 代码。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | { #<body>#} { #<div id="user">#} { # <form action="/salesman/register/" method="post" enctype="application/x-www-form-urlencoded">#} { # <h2> 添加业务员 </h2>#} { # 用户名: <input type="text" name="user_name"> {{ error_message }}{{ user_name_error }} <br/>#} { # 手机号: <input type="text" name="phone_no"> {{ phone_error_message }} {{ phone_error }} <br/>#} { # 密码 : <input type="text" name="password"> {{ password_error_message }} <br/>#} { ##} { # <input id = 'submit' type="submit" value="注册">#} { # {{ create_success }}#} { # </form>#} { #</div>#} { #</body>#} { #</html>#} |
注意使用form生成前端页面和用HTML生成模板的action是不相同的,一定要注意两着区别的
如果觉得对您有帮助,麻烦您点一下推荐,谢谢!
好记忆不如烂笔头
好记忆不如烂笔头
分类:
Django
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术