无法在表单中输入密码。 我正在制作用户注册网站。 我在views.py中写道
def regist(request):
form = RegisterForm(request.POST or None)
context = {
'form': form,
}
return render(request, 'registration/regist.html', context)
在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'
在regist.html中
<main>
<div class="container">
<div class="heading col-lg-6 col-md-12">
<h1>WEB SITE</h1>
</div>
<div class="heading col-lg-6 col-md-12">
<h2>NEW REGISTRATION</h2>
<form class="form-horizontal" method="POST">
<div class="form-group-lg">
<label for="id_username">USER NAME</label>
{{ regist_form.username }}
</div>
<div class="form-group-lg">
<label for="id_email">EMAIL</label>
{{ regist_form.email }}
</div>
<div class="form-group-lg">
<label for="id_password">PASSWORD</label>
{{ regist_form.password1 }}
</div>
<div class="form-group-lg">
<label for="id_password">PASSWORD(CONFROMATION)</label>
{{ regist_form.password2 }}
<p class="help-block">{{ regist_form.password2.help_text }}</p>
</div>
<div class="form-group-lg">
<div class="col-xs-offset-2">
<button type="submit" class="btn btn-primary btn-lg">SUBMIT</button>
<input name="next" type="hidden"/>
</div>
</div>
{% csrf_token %}
</form>
</div>
</div>
</main>
&#13;
我真的不明白为什么只能输入密码才能输入密码。可以输入用户名和电子邮件。因为我无法输入密码,所以我无法输入SEND按钮。我该如何解决这个问题?
答案 0 :(得分:0)
您是否忘记为密码添加标记。
<Input type="password" name="password" >