Django应该创建一个用于密码输入的CharField,这也应该显示在CharField上:
在HTML中:<input id="password" type="password" placeholder="Password" value="">
对于password CharField我使用:
class AuthForm(forms.Form):
username = forms.CharField(label="Your Username" )
pw = forms.CharField( widget=forms.PasswordInput(render_value=False), label="Your Password" )
对于占位符我会使用:
pw = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'Password'}))
解决方案:
它接缝不需要(render_value=False)
,因此解决方案是:
forms.CharField(widget=forms.PasswordInput(attrs={'placeholder': 'Password'}))
答案 0 :(得分:1)
根据要求复制粘贴;)
forms.CharField(widget=forms.PasswordInput(attrs={'placeholder': 'Password'}))