diff --git a/django/contrib/admin/templates/admin/edit_inline/tabular.html b/django/contrib/admin/templates/admin/edit_inline/tabular.html
index d5ac9b0..760bae7 100644
a
|
b
|
|
35 | 35 | {% for fieldset in inline_admin_form %} |
36 | 36 | {% for line in fieldset %} |
37 | 37 | {% for field in line %} |
38 | | {% if field.is_hidden %} {{ field.field }} {% endif %} |
| 38 | {% if field.field.is_hidden %} {{ field.field }} {% endif %} |
39 | 39 | {% endfor %} |
40 | 40 | {% endfor %} |
41 | 41 | {% endfor %} |
… |
… |
|
44 | 44 | {% for fieldset in inline_admin_form %} |
45 | 45 | {% for line in fieldset %} |
46 | 46 | {% for field in line %} |
| 47 | {% if not field.field.is_hidden %} |
47 | 48 | <td{% if field.field.name %} class="field-{{ field.field.name }}"{% endif %}> |
48 | 49 | {% if field.is_readonly %} |
49 | 50 | <p>{{ field.contents }}</p> |
… |
… |
|
52 | 53 | {{ field.field }} |
53 | 54 | {% endif %} |
54 | 55 | </td> |
| 56 | {% endif %} |
55 | 57 | {% endfor %} |
56 | 58 | {% endfor %} |
57 | 59 | {% endfor %} |
diff --git a/tests/regressiontests/admin_inlines/admin.py b/tests/regressiontests/admin_inlines/admin.py
index cf51fa4..6b51ad2 100644
a
|
b
|
class ChildModel2Inline(admin.StackedInline):
|
125 | 125 | model = ChildModel2 |
126 | 126 | |
127 | 127 | |
| 128 | #admin and form for #18263 |
| 129 | class SomeChildModelForm(forms.ModelForm): |
| 130 | |
| 131 | class Meta: |
| 132 | model = SomeChildModel |
| 133 | widgets = { |
| 134 | 'position': forms.HiddenInput, |
| 135 | } |
| 136 | |
| 137 | |
| 138 | class SomeChildModelInline(admin.TabularInline): |
| 139 | model = SomeChildModel |
| 140 | form = SomeChildModelForm |
| 141 | |
| 142 | |
128 | 143 | site.register(TitleCollection, inlines=[TitleInline]) |
129 | 144 | # Test bug #12561 and #12778 |
130 | 145 | # only ModelAdmin media |
… |
… |
site.register(Holder4, Holder4Admin)
|
141 | 156 | site.register(Author, AuthorAdmin) |
142 | 157 | site.register(CapoFamiglia, inlines=[ConsigliereInline, SottoCapoInline]) |
143 | 158 | site.register(ProfileCollection, inlines=[ProfileInline]) |
144 | | site.register(ParentModelWithCustomPk, inlines=[ChildModel1Inline, ChildModel2Inline]) |
145 | | No newline at end of file |
| 159 | site.register(ParentModelWithCustomPk, inlines=[ChildModel1Inline, ChildModel2Inline]) |
| 160 | site.register(SomeParentModel, inlines=[SomeChildModelInline]) |
diff --git a/tests/regressiontests/admin_inlines/models.py b/tests/regressiontests/admin_inlines/models.py
index 5a0f4d8..6cafa3b 100644
a
|
b
|
class ChildModel2(models.Model):
|
164 | 164 | return '/child_model2/' |
165 | 165 | |
166 | 166 | |
| 167 | # Models for #18263 |
| 168 | |
| 169 | class SomeParentModel(models.Model): |
| 170 | name = models.CharField(max_length=1) |
| 171 | |
| 172 | |
| 173 | class SomeChildModel(models.Model): |
| 174 | name = models.CharField(max_length=1) |
| 175 | position = models.PositiveIntegerField() |
| 176 | parent = models.ForeignKey(SomeParentModel) |
| 177 | |
167 | 178 | # Other models |
168 | 179 | |
169 | 180 | class ProfileCollection(models.Model): |
diff --git a/tests/regressiontests/admin_inlines/tests.py b/tests/regressiontests/admin_inlines/tests.py
index 4f25d3d..f904479 100644
a
|
b
|
from django.test.utils import override_settings
|
11 | 11 | from .admin import InnerInline |
12 | 12 | from .models import (Holder, Inner, Holder2, Inner2, Holder3, Inner3, Person, |
13 | 13 | OutfitItem, Fashionista, Teacher, Parent, Child, Author, Book, Profile, |
14 | | ProfileCollection, ParentModelWithCustomPk, ChildModel1, ChildModel2) |
| 14 | ProfileCollection, ParentModelWithCustomPk, ChildModel1, ChildModel2, |
| 15 | SomeParentModel, SomeChildModel) |
15 | 16 | |
16 | 17 | |
17 | 18 | @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) |
… |
… |
class TestInline(TestCase):
|
161 | 162 | self.assertContains(response, child1_shortcut) |
162 | 163 | self.assertContains(response, child2_shortcut) |
163 | 164 | |
| 165 | def test_inline_hidden_field_no_column(self): |
| 166 | """Make sure hidden fields don't get a column in tabular inlines""" |
| 167 | parent = SomeParentModel.objects.create(name='a') |
| 168 | SomeChildModel.objects.create(name='b', position='0', parent=parent) |
| 169 | SomeChildModel.objects.create(name='c', position='1', parent=parent) |
| 170 | response = self.client.get('/admin/admin_inlines/someparentmodel/%s/' % parent.pk) |
| 171 | self.assertNotContains(response, '<td class="field-position">') |
| 172 | |
164 | 173 | |
165 | 174 | @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) |
166 | 175 | class TestInlineMedia(TestCase): |