Django form - Add placeholder text to a form field

Here is how I add placeholder text to a Django form field, for example:

from django import forms

class SearchForm(forms.Form):
email = EmailField(widget=forms.TextInput(attrs={'placeholder': 'Email'}))


In the template:

{{ search_form.email }}

It will be rendered as:


Comments