diff --git a/django/contrib/admin/templates/admin/edit_inline/tabular.html b/django/contrib/admin/templates/admin/edit_inline/tabular.html index 29db95a171b..ea0ca8c7321 100644 --- a/django/contrib/admin/templates/admin/edit_inline/tabular.html +++ b/django/contrib/admin/templates/admin/edit_inline/tabular.html @@ -9,7 +9,9 @@ {% for field in inline_admin_formset.fields %} {% if not field.widget.is_hidden %} - {{ field.label|capfirst }} + {{ field.label|capfirst }} + {% if field.help_text %} ({{ field.help_text|striptags }}){% endif %} + {% endif %} {% endfor %} {% if inline_admin_formset.formset.can_delete %}{% trans "Delete?" %}{% endif %} diff --git a/tests/regressiontests/admin_inlines/models.py b/tests/regressiontests/admin_inlines/models.py index ee0abd1d3d4..8d9ca7c3e9a 100644 --- a/tests/regressiontests/admin_inlines/models.py +++ b/tests/regressiontests/admin_inlines/models.py @@ -103,6 +103,32 @@ admin.site.register(Holder2, HolderAdmin, inlines=[InnerInline2]) # only Inline media admin.site.register(Holder3, inlines=[InnerInline3]) + +# Models for ticket #8190 + +class Holder4(models.Model): + dummy = models.IntegerField() + +class Inner4Stacked(models.Model): + dummy = models.IntegerField(help_text="Awesome stacked help text is awesome.") + holder = models.ForeignKey(Holder4) + +class Inner4Tabular(models.Model): + dummy = models.IntegerField(help_text="Awesome tabular help text is awesome.") + holder = models.ForeignKey(Holder4) + +class Inner4StackedInline(admin.StackedInline): + model = Inner4Stacked + +class Inner4TabularInline(admin.TabularInline): + model = Inner4Tabular + +class Holder4Admin(admin.ModelAdmin): + inlines = [Inner4StackedInline, Inner4TabularInline] + +admin.site.register(Holder4, Holder4Admin) + + # Models for #12749 class Person(models.Model): diff --git a/tests/regressiontests/admin_inlines/tests.py b/tests/regressiontests/admin_inlines/tests.py index 067b3c5eaf2..61d4634f8bf 100644 --- a/tests/regressiontests/admin_inlines/tests.py +++ b/tests/regressiontests/admin_inlines/tests.py @@ -103,6 +103,16 @@ class TestInline(TestCase): # column cells self.assertContains(response, '

Callable in QuestionInline

') + def test_help_text(self): + """ + Ensure that the inlines' model field help texts are displayed when + using both the stacked and tabular layouts. + Ref #8190. + """ + response = self.client.get('/test_admin/admin/admin_inlines/holder4/add/') + self.assertContains(response, '

Awesome stacked help text is awesome.

', 4) + self.assertContains(response, '(Awesome tabular help text is awesome.)', 1) + class TestInlineMedia(TestCase): fixtures = ['admin-views-users.xml']