diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py index 5bbfcbe41c..62d1823d57 100644 --- a/django/forms/boundfield.py +++ b/django/forms/boundfield.py @@ -145,7 +145,7 @@ class BoundField: initial_value = self.initial return field.has_changed(initial_value, self.data) - def label_tag(self, contents=None, attrs=None, label_suffix=None): + def label_tag(self, contents=None, attrs=None, label_suffix=None, tag=None): """ Wrap the given contents in a {% else %}{{ label }}{% endif %} +{% if use_tag %}<{{ tag }}{% if attrs %}{% include 'django/forms/attrs.html' %}{% endif %}>{{ label }}{% else %}{{ label }}{% endif %} diff --git a/django/forms/templates/django/forms/label.html b/django/forms/templates/django/forms/label.html index eb2a9f7973..0eba630e82 100644 --- a/django/forms/templates/django/forms/label.html +++ b/django/forms/templates/django/forms/label.html @@ -1 +1 @@ -{% if use_tag %}{{ label }}{% else %}{{ label }}{% endif %} +{% if use_tag %}<{{ tag }}{% include 'django/forms/attrs.html' %}>{{ label }}{% else %}{{ label }}{% endif %} diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt index d80d9ea224..e092a2f59e 100644 --- a/docs/ref/forms/api.txt +++ b/docs/ref/forms/api.txt @@ -542,9 +542,9 @@ default template, see also :ref:`overriding-built-in-form-templates`. .. attribute:: Form.template_name_label The template used to render a field's ``