I want to place a placeholder in my forms textarea in Django

Issue

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

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.

Answered By – David Lu

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published