Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #8190 -- Added support for a field's help text to the tabular a…

…dmin inline. Thanks, Julien Phalip and Idan Gazit.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16622 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 7d782e51c1531683c7719a4d3dcf9b3ce38ebfbd 1 parent 0e3d8bc
Jannis Leidel jezdez authored
4 django/contrib/admin/templates/admin/edit_inline/tabular.html
View
@@ -9,7 +9,9 @@
<thead><tr>
{% for field in inline_admin_formset.fields %}
{% if not field.widget.is_hidden %}
- <th{% if forloop.first %} colspan="2"{% endif %}{% if field.required %} class="required"{% endif %}>{{ field.label|capfirst }}</th>
+ <th{% if forloop.first %} colspan="2"{% endif %}{% if field.required %} class="required"{% endif %}>{{ field.label|capfirst }}
+ {% if field.help_text %}&nbsp;<img src="{% static "admin/img/icon-unknown.gif" %}" alt="({{ field.help_text|striptags }})" title="{{ field.help_text|striptags }}" />{% endif %}
+ </th>
{% endif %}
{% endfor %}
{% if inline_admin_formset.formset.can_delete %}<th>{% trans "Delete?" %}</th>{% endif %}
26 tests/regressiontests/admin_inlines/models.py
View
@@ -103,6 +103,32 @@ class Media:
# 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):
10 tests/regressiontests/admin_inlines/tests.py
View
@@ -103,6 +103,16 @@ def test_callable_lookup(self):
# column cells
self.assertContains(response, '<p>Callable in QuestionInline</p>')
+ 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, '<p class="help">Awesome stacked help text is awesome.</p>', 4)
+ self.assertContains(response, '<img src="/static/admin/img/icon-unknown.gif" alt="(Awesome tabular help text is awesome.)" title="Awesome tabular help text is awesome." />', 1)
+
class TestInlineMedia(TestCase):
fixtures = ['admin-views-users.xml']
Please sign in to comment.
Something went wrong with that request. Please try again.