Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Documented BoundField.label_tag

  • Loading branch information...
commit 0f99246b6f4e7d08600c19fbbeb8feb1a335f985 1 parent 712a792
@claudep claudep authored
Showing with 13 additions and 0 deletions.
  1. +13 −0 docs/ref/forms/api.txt
13 docs/ref/forms/api.txt
@@ -639,6 +639,19 @@ For a field's list of errors, access the field's ``errors`` attribute.
>>> str(f['subject'].errors)
+.. method:: BoundField.label_tag(contents=None, attrs=None)
+To separately render the label tag of a form field, you can call its
+``label_tag`` method::
+ >>> f = ContactForm(data)
+ >>> print(f['message'].label_tag())
+ <label for="id_message">Message</label>
+Optionally, you can provide the ``contents`` parameter which will replace the
+auto-generated label tag. An optional ``attrs`` dictionary may contain
+additional attributes for the ``<label>`` tag.
.. method:: BoundField.css_classes()
When you use Django's rendering shortcuts, CSS classes are used to

0 comments on commit 0f99246

Please sign in to comment.
Something went wrong with that request. Please try again.