答案 0 :(得分:0)
class CustomerLoginFrom(ModelForm):
class Meta:
model = UserLogin
fields = ['user_name','password']
labels = {
"user_name": "*Username",
"password": "*Password"
}
widgets = {
"user_name": TextInput(attrs={'placeholder':'ex:test','autocomplete': 'off'}),
"password": PasswordInput(attrs={'placeholder':'********','autocomplete': 'off','data-toggle:password'}),
}
<input type="password" id="password" name="password" class="form-control" data-toggle="password">
Django密码字段可将HTML属性直接添加到Django表单attrs,它对我有用。