[PYTHON] Set placeholders in input fields in Django

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.

無題.png

Recommended Posts

Set placeholders in input fields in Django
Dynamically add form fields in Django
Models in Django
Forms in Django
Key input in Python
Set spinning_friction in pybullet
Set ulimit in supervisor
Set the form DateField to type = date in Django
Model changes in Django
Key input in Python
Implementing Add Form Buttons in Django Inline Forms Set Part2
[Django] How to give input values in advance with ModelForm
Implement an add form button in your Django inline form set
Performance optimization in Django 3.xx
Dynamically set env.hosts in fabric
PHP var_dump in Django templates
Handle constants in Django templates
Write standard input in code
Rename table columns in Django3
Output table structure in Django
Python Input Note in AtCoder
django data input dumpdata loaddata
Methods available in set type
(Note) Django in Vagrant environment
Django input check and calendar input
Set up Nunjucks in Node.js
Show Django ManyToManyField in Template
Set python test in jenkins