'I want to place a placeholder in my forms textarea in Django
I want to write a placeholder at the end of the textarea says: '*required'. How can I do this for my fields?
forms.py
class CustomerForm2(forms.ModelForm):
class Meta:
model = Customer
fields = (
'order_id','full_name','company','email',
'phone_number','note')
}
Solution 1:[1]
You can add the following code in CustomerForm2 form.
class CustomerForm2(forms.ModelForm):
note= forms.CharField(
required=True,
widget=forms.Textarea(
attrs={"placeholder": "*required",}
),
)
class Meta:
...
Hope it could help.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | David Lu |
