Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 authored August 17, 2011
4  django/contrib/admin/templates/admin/edit_inline/tabular.html
@@ -9,7 +9,9 @@
9 9
      <thead><tr>
10 10
      {% for field in inline_admin_formset.fields %}
11 11
        {% if not field.widget.is_hidden %}
12  
-         <th{% if forloop.first %} colspan="2"{% endif %}{% if field.required %} class="required"{% endif %}>{{ field.label|capfirst }}</th>
  12
+         <th{% if forloop.first %} colspan="2"{% endif %}{% if field.required %} class="required"{% endif %}>{{ field.label|capfirst }}
  13
+         {% if field.help_text %}&nbsp;<img src="{% static "admin/img/icon-unknown.gif" %}" alt="({{ field.help_text|striptags }})" title="{{ field.help_text|striptags }}" />{% endif %}
  14
+         </th>
13 15
        {% endif %}
14 16
      {% endfor %}
15 17
      {% if inline_admin_formset.formset.can_delete %}<th>{% trans "Delete?" %}</th>{% endif %}
26  tests/regressiontests/admin_inlines/models.py
@@ -103,6 +103,32 @@ class Media:
103 103
 # only Inline media
104 104
 admin.site.register(Holder3, inlines=[InnerInline3])
105 105
 
  106
+
  107
+# Models for ticket #8190
  108
+
  109
+class Holder4(models.Model):
  110
+    dummy = models.IntegerField()
  111
+
  112
+class Inner4Stacked(models.Model):
  113
+    dummy = models.IntegerField(help_text="Awesome stacked help text is awesome.")
  114
+    holder = models.ForeignKey(Holder4)
  115
+
  116
+class Inner4Tabular(models.Model):
  117
+    dummy = models.IntegerField(help_text="Awesome tabular help text is awesome.")
  118
+    holder = models.ForeignKey(Holder4)
  119
+
  120
+class Inner4StackedInline(admin.StackedInline):
  121
+    model = Inner4Stacked
  122
+
  123
+class Inner4TabularInline(admin.TabularInline):
  124
+    model = Inner4Tabular
  125
+
  126
+class Holder4Admin(admin.ModelAdmin):
  127
+    inlines = [Inner4StackedInline, Inner4TabularInline]
  128
+
  129
+admin.site.register(Holder4, Holder4Admin)
  130
+
  131
+
106 132
 # Models for #12749
107 133
 
108 134
 class Person(models.Model):
10  tests/regressiontests/admin_inlines/tests.py
@@ -103,6 +103,16 @@ def test_callable_lookup(self):
103 103
         # column cells
104 104
         self.assertContains(response, '<p>Callable in QuestionInline</p>')
105 105
 
  106
+    def test_help_text(self):
  107
+        """
  108
+        Ensure that the inlines' model field help texts are displayed when
  109
+        using both the stacked and tabular layouts.
  110
+        Ref #8190.
  111
+        """
  112
+        response = self.client.get('/test_admin/admin/admin_inlines/holder4/add/')
  113
+        self.assertContains(response, '<p class="help">Awesome stacked help text is awesome.</p>', 4)
  114
+        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)
  115
+
106 116
 class TestInlineMedia(TestCase):
107 117
     fixtures = ['admin-views-users.xml']
108 118
 

0 notes on commit 7d782e5

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