按钮在注册表单中不起作用

Button doesn't work in registration form

一切正常,但注册文档中的按钮不起作用,单击它时没有任何反应...我在下面添加了 URL、视图和模板的代码 网址

from django.conf.urls import url
from . import views

urlpatterns = [
url(r'^register', views.register , name = 'register'),

]

观看次数

def register(request):
if request.method == 'POST':
    form = UserCreationForm(request.POST)
    if form.is_valid():
        form.save()
        return redirect('/index')
    else:
        form = UserCreationForm()
else:
    form = UserCreationForm()

    args = {'form': form}
    return render(request, 'reg.html',args)

REG.html

<!DOCTYPE html>
<html>
<head>
<title>Register</title>
{% load staticfiles %}
</head>
    <link rel="stylesheet" href=" {% static 'css/bootstrap.min.css' %}" type = 'text/css'/>
    <link rel="stylesheet" href=" {% static 'css/bootstrap-theme.min.css' %}" type = 'text/css'/>
    <link rel="stylesheet" href=" {% static 'css/fontAwesome.css' %}" type = 'text/css'/>
    <link rel="stylesheet" href=" {% static 'css/tooplate-style.css' %}" type = 'text/css'/>

<body>
<div class="container-fluid">
    <h1> Registration form</h1><br>
    <img src="{% static 'img/53471658c4ed95e72a2ed6058361a367.jpg' %}" alt="HI" align="right">


<form method="post">

{{ form.as_ul }}
<br>
 <button type="button" class="btn btn-primary">Register</button>


 </form>


  </div>

    </body> 
  </html>

尝试将类型更改为 "submit" 并向您的按钮添加一个值 "Submit"。另外,向您的表单添加一个动作。

<form method="post" action="">

    {{ form.as_ul }}
    <br>
    <button type="submit" value="Submit" class="btn btn-primary">Register</button>
</form>