'Wraps the given contents in a <label>, if the field has an ID attribute.
Does not HTML-escape the contents. If contents aren\'t given, uses the
field\'s HTML-escaped label.
If attrs are given, they\'re used as HTML attributes on the <label> tag.'

def label_tag(self, contents=None, attrs=None):

    contents = (contents or conditional_escape(self.label))
    widget = self.field.widget
    id_ = (widget.attrs.get('id') or self.auto_id)
    if id_:
        attrs = ((attrs and flatatt(attrs)) or '')
        contents = (u'<label    for="%s"%s>%s</label>' % (widget.id_for_label(id_), attrs, unicode(contents)))
    return mark_safe(contents)
