Extremely quick blog post!
Here's how to make a crude template tag which lets you add the HTML5 'placeholder' attribute to your form field inputs and textareas in a Django template.
from django.template import Library | |
import re | |
register = Library() | |
def placeholder(value, token): | |
value.field.widget.attrs["placeholder"] = token | |
return value | |
register.filter(placeholder) |
Drop this in /yourproject/yourapp/templatetags/ as placeholder.py, and then you're done!