NoReverseMatch at /salesman/zhuce/
Reverse for '/zhuce/' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: [] 对于上面的错误,有可能是django模板的错误,下面我粘贴出来错误的配置代码 一. 错误代码,错误部门用红色字体标出
错误配置
<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 代码。
{#<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是不相同的,一定要注意两着区别的