I have a django model that I’m displaying as a form using a ModelForm. The defaults work very well for me for the most part.
However, I would like my html <input ...> tags to have one additional attribute, namely I would like to include a placeholder attribute, like the following:
<input placeholder="{{field.label}}" ... />
What is the easiest way to add this attribute to my html? As far as I can tell it appears I need to implement my own filter to output the field, but this seems like overkill when all i want to do is leave everything alone but add one additional attribute.
See the documentation
You could always create your own widget that derives from TextInput and includes the placeholder attribute, and use the widgets dictionary to simply map fields to your new widget without specifying the placeholder attribute for every field.