mirror of https://github.com/django/django.git
Fixed #8190 -- Added support for a field's help text to the tabular admin inline. Thanks, Julien Phalip and Idan Gazit.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16622 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
0e3d8bcb26
commit
7d782e51c1
|
@ -9,7 +9,9 @@
|
||||||
<thead><tr>
|
<thead><tr>
|
||||||
{% for field in inline_admin_formset.fields %}
|
{% for field in inline_admin_formset.fields %}
|
||||||
{% if not field.widget.is_hidden %}
|
{% 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 %} <img src="{% static "admin/img/icon-unknown.gif" %}" alt="({{ field.help_text|striptags }})" title="{{ field.help_text|striptags }}" />{% endif %}
|
||||||
|
</th>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if inline_admin_formset.formset.can_delete %}<th>{% trans "Delete?" %}</th>{% endif %}
|
{% if inline_admin_formset.formset.can_delete %}<th>{% trans "Delete?" %}</th>{% endif %}
|
||||||
|
|
|
@ -103,6 +103,32 @@ admin.site.register(Holder2, HolderAdmin, inlines=[InnerInline2])
|
||||||
# only Inline media
|
# only Inline media
|
||||||
admin.site.register(Holder3, inlines=[InnerInline3])
|
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
|
# Models for #12749
|
||||||
|
|
||||||
class Person(models.Model):
|
class Person(models.Model):
|
||||||
|
|
|
@ -103,6 +103,16 @@ class TestInline(TestCase):
|
||||||
# column cells
|
# column cells
|
||||||
self.assertContains(response, '<p>Callable in QuestionInline</p>')
|
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):
|
class TestInlineMedia(TestCase):
|
||||||
fixtures = ['admin-views-users.xml']
|
fixtures = ['admin-views-users.xml']
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue