'Wraps the given contents in a <label>, if the field has an ID attribute.
contents should be \'mark_safe\'d to avoid HTML escaping. 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(u'id') or self.auto_id)
    if id_:
        attrs = ((attrs and flatatt(attrs)) or u'')
        contents = format_html(u'<label    for="{0}"{1}>{2}</label>', widget.id_for_label(id_), attrs, contents)
    return mark_safe(contents)
