Skip to content

Instantly share code, notes, and snippets.

@lehmannro
Created September 23, 2010 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lehmannro/593270 to your computer and use it in GitHub Desktop.
Save lehmannro/593270 to your computer and use it in GitHub Desktop.
HTML5 placeholder for Django forms
from django.forms.forms import BoundField
boundfield_as_widget = BoundField.as_widget
def as_widget(self, widget=None, attrs=None, only_initial=False):
if attrs is None:
attrs = {}
attrs['placeholder'] = self.label
return boundfield_as_widget(self, widget=widget, attrs=attrs,
only_initial=only_initial)
BoundField.as_widget = as_widget
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment