📜  模型形式的占位符 - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:23.659000             🧑  作者: Mango

代码示例1
class LoginForm(forms.Form):
    username = forms.CharField(label='username')
    password = forms.CharField(label='password')


    def __init__(self, *args, **kwargs):
        super(LoginForm, self).__init__(*args, **kwargs)
        self.fields['username'].widget.attrs['placeholder'] = 'username'
        self.fields['password '].widget.attrs['placeholder'] = 'password'