diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py
index 3ffb85e..ebf8c5c 100644
a
|
b
|
class AdminField(object):
|
125 | 125 | contents = conditional_escape(force_text(self.field.label)) |
126 | 126 | if self.is_checkbox: |
127 | 127 | classes.append('vCheckboxLabel') |
128 | | else: |
129 | | contents += ':' |
| 128 | |
130 | 129 | if self.field.field.required: |
131 | 130 | classes.append('required') |
132 | 131 | if not self.is_first: |
133 | 132 | classes.append('inline') |
134 | 133 | attrs = {'class': ' '.join(classes)} if classes else {} |
135 | | return self.field.label_tag(contents=mark_safe(contents), attrs=attrs) |
| 134 | return self.field.label_tag(contents=mark_safe(contents), attrs=attrs, |
| 135 | include_label_suffix=not self.is_checkbox) |
136 | 136 | |
137 | 137 | def errors(self): |
138 | 138 | return mark_safe(self.field.errors.as_ul()) |
diff --git a/django/forms/forms.py b/django/forms/forms.py
index e144eb6..a914d0e 100644
a
|
b
|
class BoundField(object):
|
509 | 509 | ) |
510 | 510 | return self.field.prepare_value(data) |
511 | 511 | |
512 | | def label_tag(self, contents=None, attrs=None): |
| 512 | def label_tag(self, contents=None, attrs=None, include_label_suffix=True): |
513 | 513 | """ |
514 | 514 | Wraps the given contents in a <label>, if the field has an ID attribute. |
515 | 515 | contents should be 'mark_safe'd to avoid HTML escaping. If contents |
… |
… |
class BoundField(object):
|
521 | 521 | # Only add the suffix if the label does not end in punctuation. |
522 | 522 | # Translators: If found as last label character, these punctuation |
523 | 523 | # characters will prevent the default label_suffix to be appended to the label |
524 | | if self.form.label_suffix and contents and contents[-1] not in _(':?.!'): |
| 524 | if include_label_suffix and self.form.label_suffix and contents and contents[-1] not in _(':?.!'): |
525 | 525 | contents = format_html('{0}{1}', contents, self.form.label_suffix) |
526 | 526 | widget = self.field.widget |
527 | 527 | id_ = widget.attrs.get('id') or self.auto_id |
diff --git a/tests/admin_util/tests.py b/tests/admin_util/tests.py
index 637f643..4a9a203 100644
a
|
b
|
class UtilTests(SimpleTestCase):
|
301 | 301 | self.assertHTMLEqual(helpers.AdminField(form, 'text', is_first=False).label_tag(), |
302 | 302 | '<label for="id_text" class="required inline"><i>text</i>:</label>') |
303 | 303 | self.assertHTMLEqual(helpers.AdminField(form, 'cb', is_first=False).label_tag(), |
304 | | '<label for="id_cb" class="vCheckboxLabel required inline"><i>cb</i>:</label>') |
| 304 | '<label for="id_cb" class="vCheckboxLabel required inline"><i>cb</i></label>') |
305 | 305 | |
306 | 306 | # normal strings needs to be escaped |
307 | 307 | class MyForm(forms.Form): |
… |
… |
class UtilTests(SimpleTestCase):
|
312 | 312 | self.assertHTMLEqual(helpers.AdminField(form, 'text', is_first=False).label_tag(), |
313 | 313 | '<label for="id_text" class="required inline">&text:</label>') |
314 | 314 | self.assertHTMLEqual(helpers.AdminField(form, 'cb', is_first=False).label_tag(), |
315 | | '<label for="id_cb" class="vCheckboxLabel required inline">&cb:</label>') |
| 315 | '<label for="id_cb" class="vCheckboxLabel required inline">&cb</label>') |
316 | 316 | |
317 | 317 | def test_flatten_fieldsets(self): |
318 | 318 | """ |