diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py
a
|
b
|
|
132 | 132 | first = True |
133 | 133 | pk = cl.lookup_opts.pk.attname |
134 | 134 | for field_name in cl.list_display: |
135 | | row_class = '' |
| 135 | row_classes = ['fldname-%s' % field_name] |
136 | 136 | try: |
137 | 137 | f, attr, value = lookup_field(field_name, result, cl.model_admin) |
138 | 138 | except (AttributeError, ObjectDoesNotExist): |
… |
… |
|
140 | 140 | else: |
141 | 141 | if f is None: |
142 | 142 | if field_name == u'action_checkbox': |
143 | | row_class = ' class="action-checkbox"' |
| 143 | row_classes = ['action-checkbox'] |
144 | 144 | allow_tags = getattr(attr, 'allow_tags', False) |
145 | 145 | boolean = getattr(attr, 'boolean', False) |
146 | 146 | if boolean: |
… |
… |
|
166 | 166 | if isinstance(f, models.DateField)\ |
167 | 167 | or isinstance(f, models.TimeField)\ |
168 | 168 | or isinstance(f, models.ForeignKey): |
169 | | row_class = ' class="nowrap"' |
| 169 | row_classes.append('nowrap') |
170 | 170 | if force_unicode(result_repr) == '': |
171 | 171 | result_repr = mark_safe(' ') |
| 172 | row_class = ' class="%s"' % ' '.join(row_classes) |
172 | 173 | # If list_display_links not defined, add the link tag to the first field |
173 | 174 | if (first and not cl.list_display_links) or field_name in cl.list_display_links: |
174 | 175 | table_tag = {True:'th', False:'td'}[first] |
diff --git a/tests/regressiontests/admin_changelist/tests.py b/tests/regressiontests/admin_changelist/tests.py
a
|
b
|
|
36 | 36 | template = Template('{% load admin_list %}{% spaceless %}{% result_list cl %}{% endspaceless %}') |
37 | 37 | context = Context({'cl': cl}) |
38 | 38 | table_output = template.render(context) |
39 | | row_html = '<tbody><tr class="row1"><td class="action-checkbox"><input type="checkbox" class="action-select" value="1" name="_selected_action" /></td><th><a href="1/">name</a></th><td class="nowrap">(None)</td></tr></tbody>' |
| 39 | row_html = '<tbody><tr class="row1"><td class="action-checkbox"><input type="checkbox" class="action-select" value="1" name="_selected_action" /></td><th class="fldname-name"><a href="1/">name</a></th><td class="fldname-parent nowrap">(None)</td></tr></tbody>' |
40 | 40 | self.assertFalse(table_output.find(row_html) == -1, |
41 | 41 | 'Failed to find expected row element: %s' % table_output) |
42 | 42 | |
… |
… |
|
57 | 57 | template = Template('{% load admin_list %}{% spaceless %}{% result_list cl %}{% endspaceless %}') |
58 | 58 | context = Context({'cl': cl}) |
59 | 59 | table_output = template.render(context) |
60 | | row_html = '<tbody><tr class="row1"><td class="action-checkbox"><input type="checkbox" class="action-select" value="1" name="_selected_action" /></td><th><a href="1/">name</a></th><td class="nowrap">Parent object</td></tr></tbody>' |
| 60 | row_html = '<tbody><tr class="row1"><td class="action-checkbox"><input type="checkbox" class="action-select" value="1" name="_selected_action" /></td><th class="fldname-name"><a href="1/">name</a></th><td class="fldname-parent nowrap">Parent object</td></tr></tbody>' |
61 | 61 | self.assertFalse(table_output.find(row_html) == -1, |
62 | 62 | 'Failed to find expected row element: %s' % table_output) |
63 | 63 | |
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
a
|
b
|
|
1052 | 1052 | response = self.client.get('/test_admin/admin/admin_views/plot/%s/delete/' % quote(3)) |
1053 | 1053 | self.assertContains(response, should_contain) |
1054 | 1054 | |
| 1055 | class AdminChangeListFieldNameClassAttrTest(TestCase): |
| 1056 | fixtures = ['admin-views-users.xml'] |
| 1057 | |
| 1058 | def setUp(self): |
| 1059 | self.client.login(username='super', password='secret') |
| 1060 | |
| 1061 | def tearDown(self): |
| 1062 | self.client.logout() |
| 1063 | |
| 1064 | def test_class_attributes(self): |
| 1065 | "Cells of the change list table should contain the field name in their class attribute" |
| 1066 | Podcast.objects.create(name="Django Dose", |
| 1067 | release_date=datetime.date.today()) |
| 1068 | response = self.client.get('/test_admin/admin/admin_views/podcast/') |
| 1069 | self.assertContains( |
| 1070 | response, '<th class="fldname-name">') |
| 1071 | self.assertContains( |
| 1072 | response, '<td class="fldname-release_date nowrap">') |
| 1073 | self.assertContains( |
| 1074 | response, '<td class="action-checkbox">') |
| 1075 | |
1055 | 1076 | class AdminViewStringPrimaryKeyTest(TestCase): |
1056 | 1077 | fixtures = ['admin-views-users.xml', 'string-primary-key.xml'] |
1057 | 1078 | |
… |
… |
|
1082 | 1103 | def test_changelist_to_changeform_link(self): |
1083 | 1104 | "The link from the changelist referring to the changeform of the object should be quoted" |
1084 | 1105 | response = self.client.get('/test_admin/admin/admin_views/modelwithstringprimarykey/') |
1085 | | should_contain = """<th><a href="%s/">%s</a></th></tr>""" % (quote(self.pk), escape(self.pk)) |
| 1106 | should_contain = """<th class="fldname-__str__"><a href="%s/">%s</a></th></tr>""" % (quote(self.pk), escape(self.pk)) |
1086 | 1107 | self.assertContains(response, should_contain) |
1087 | 1108 | |
1088 | 1109 | def test_recentactions_link(self): |