首先,我将尝试使用原生 HTML 和 jquery 来解决这个问题,但我想以 Django 形式解决这个问题,而不需要任何脚本。
我会尝试this https://itsolutionstuff.com/post/bootstrap-show-hidetoggle-password-input-field-using-bootstrap-show-passwordjs-pluginexample.html源代码。
我的预期输出是将这个相同的示例放在上面的 Django 表单链接中。
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,它对我有用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)