Is there a way to use input text placeholder when using {{ form.as_p }}

13 views
Skip to first unread message

Alexander Joseph

unread,
Jul 26, 2017, 4:31:58 PM7/26/17
to Django users
I'm using {{ form.as_p }} in my template and would like to be able to use placeholders in the individual input fields. Is there a way to do this? Thanks

Lee Hinde

unread,
Jul 26, 2017, 4:41:52 PM7/26/17
to django...@googlegroups.com
in the init method of your form do something like this:

self.fields['verification_date'].widget.attrs["placeholder"] = 'date'

Alexander Joseph

unread,
Jul 26, 2017, 5:26:10 PM7/26/17
to Django users
Perfect, thanks!
Reply all
Reply to author
Forward
0 new messages