我的应用程序的注册页面显示异常行为。我正在使用标准的Django身份验证。稍微编辑html之后,表单完全停止提交。就像在我单击“提交”时没有任何事情一样。 与此chap,此one和此question类似。
我已修复它。由于某种原因,我需要添加一个额外的开始表单标签。我不知道为什么。这就是html现在的样子:
<form method="POST">
<form method="POST">
{% csrf_token %}
{{ form.non_field_errors }}
{% bootstrap_form form %}
<input type="submit" class='btn btn-primary' value="Sign Up"/>
</form>
顶部没有附加的表单标签,它不起作用。谁能解释这是怎么回事?
我还注意到,在Atom中,当我只有一个开始标签时,编辑器以橙色突出显示该标签-这意味着该标签被视为属性而不是标签。当我同时拥有两个开始标记时,一个仍然会突出显示为属性。
就像我说的那样,它现在正在运行,但是如果社区中的任何人都可以提供帮助,我希望纠正它。
这是表单在浏览器中的呈现方式:
<div class="login-form">
<h3 style="text-align: center;"><b>Create an Account</b></h3>
<div class="container" <form="" method="POST">
<form method="POST">
<input type="hidden" name="csrfmiddlewaretoken" value="IX6HkTrNGNfH5CKgRtvp5II9vzg2fAUshMjlOe">
<div class="form-group"><label class="control-label" for="id_username">Display Name</label><input type="text" name="username" maxlength="150" autofocus="" class="form-control" placeholder="Display Name" title="Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only." required="" id="id_username">
<div class="help-block">Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.</div>
</div>
<div class="form-group"><label class="control-label" for="id_email">Email Address</label><input type="email" name="email" maxlength="254" class="form-control" placeholder="Email Address" title="" id="id_email"></div>
<div class="form-group"><label class="control-label" for="id_password1">Password</label><input type="password" name="password1" class="form-control" placeholder="Password" title="Your password can&#39;t be too similar to your other personal information.Your password must contain at least 8 characters.Your password can&#39;t be a commonly used password.Your password can&#39;t be entirely numeric." required="" id="id_password1">
<div class="help-block"><ul><li>Your password can't be too similar to your other personal information.</li><li>Your password must contain at least 8 characters.</li><li>Your password can't be a commonly used password.</li><li>Your password can't be entirely numeric.</li></ul></div>
</div>
<div class="form-group"><label class="control-label" for="id_password2">Password confirmation</label><input type="password" name="password2" class="form-control" placeholder="Password confirmation" title="Enter the same password as before, for verification." required="" id="id_password2">
<div class="help-block">Enter the same password as before, for verification.</div>
</div>
<input type="submit" class="btn btn-primary" value="Sign Up">
</form>
</div>
</div>
答案 0 :(得分:0)
在打开div
标签之前,您有一个未关闭的form
标签。