输入来自html中只有1个。我在index.html中创建了Login表单,如
<form class="my-form" action="{% url 'accounts:regist_save' %}" method="POST">
<div class="form-group">
<label for="id_username">Username</label>
{{ form.username }}
{{ form.username.errors }}
</div>
<div class="form-group">
<label for="id_email">Email</label>
{{ form.email }}
{{ form.email.errors }}
</div>
<div class="form-group">
<label class="control-label" for="id_password1">Password</label>
{{ form.password1 }}
{{ form.password1.errors }}
</div>
<div class="form-group">
<label class ="control-label" for="id_password2">Password(Conformation)</label>
{{ form.password2 }}
{{ form.password2.errors }}
<p class="help-block">{{ form.password2.help_text }}</p>
</div>
<div class="form-group">
<div>
<input type="submit" class="btn btn-default" value="SEND">
</div>
</div>
{% csrf_token %}
</form>
在forms.py
中class RegisterForm(UserCreationForm):
class Meta:
model = User
fields = ('username', 'email',)
def __init__(self, *args, **kwargs):
super(RegisterForm, self).__init__(*args, **kwargs)
self.fields['username'].widget.attrs['class'] = 'form-control'
self.fields['email'].widget.attrs['class'] = 'form-control'
self.fields['password1'].widget.attrs['class'] = 'form-control'
self.fields['password2'].widget.attrs['class'] = 'form-control'
在urls.py中
urlpatterns = [
url(r'^login/$', login,{'template_name': 'index.html'},name='login'),
]
只有用户名字段显示在浏览器中,但其他人不在那里。通过使用谷歌验证,只有用户名字段有输入标签,但其他人没有。为什么会发生?我该如何解决这个问题?