Django:1.10
It was listed below.
Widgets | Django documentation | Django https://docs.djangoproject.com/ja/1.10/ref/forms/widgets/#customizing-widget-instances
I see, I think I should specify it as attrs.
forms.py
class LoginForm(forms.Form):
username = forms.CharField(label='LOGIN_ID', max_length=30,
widget=forms.TextInput(
attrs={'placeholder':'User name', 'class':'class_name'}))
password = forms.CharField(
label='PASSWORD', max_length=128,
widget=forms.PasswordInput(
attrs={'placeholder':'password', 'class':'class_name'}))
The placeholder is displayed.
Recommended Posts