Home > database >  I want to place a placeholder in my forms textarea in Django
I want to place a placeholder in my forms textarea in Django

Time:05-18

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')


        }

CodePudding user response:

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.

  • Related