【发布时间】:2019-06-05 13:08:47
【问题描述】:
我的应用的注册页面出现意外行为。我正在使用标准的 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>
【问题讨论】:
-
能否包含表单在浏览器中呈现方式的 HTML?转到您的页面并右键单击 -> 显示源。然后复制整个
<form>部分。 -
请显示您生成的 HTML....(打开页面后)
-
完成。有帮助吗?
标签: html django django-forms