diff --git a/django/contrib/admin/templates/admin/edit_inline/tabular.html b/django/contrib/admin/templates/admin/edit_inline/tabular.html index 71b097e9d9e..b891a76a72b 100644 --- a/django/contrib/admin/templates/admin/edit_inline/tabular.html +++ b/django/contrib/admin/templates/admin/edit_inline/tabular.html @@ -44,7 +44,7 @@ {% for fieldset in inline_admin_form %} {% for line in fieldset %} {% for field in line %} - + {% if field.is_readonly %}

{{ field.contents }}

{% else %} diff --git a/django/contrib/admin/templates/admin/includes/fieldset.html b/django/contrib/admin/templates/admin/includes/fieldset.html index 6363aeeee4f..0b71d501f9a 100644 --- a/django/contrib/admin/templates/admin/includes/fieldset.html +++ b/django/contrib/admin/templates/admin/includes/fieldset.html @@ -4,7 +4,7 @@
{{ fieldset.description|safe }}
{% endif %} {% for line in fieldset %} -
+
{% if line.fields|length_is:'1' %}{{ line.errors }}{% endif %} {% for field in line %} diff --git a/docs/releases/1.4.txt b/docs/releases/1.4.txt index c6b547dab6d..b71fd21daa7 100644 --- a/docs/releases/1.4.txt +++ b/docs/releases/1.4.txt @@ -431,6 +431,16 @@ files were removed and grouped into two sprite files, respectively: those icons to customize the admin then you will want to replace them with your own icons or retrieve them from a previous release. +CSS class names in admin forms +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To avoid conflicts with other common CSS class names (e.g. "button"), a prefix +"field-" has been added to all CSS class names automatically generated from the +form field names in the main admin forms, stacked inline forms and tabular +inline cells. You will need to take that prefix into account in your custom +style sheets or javascript files if you previously used plain field names as +selectors for custom styles or javascript transformations. + Compatibility with old signed data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py index b6e7b9ebbb2..b15e97af1f3 100644 --- a/tests/regressiontests/admin_views/tests.py +++ b/tests/regressiontests/admin_views/tests.py @@ -2786,11 +2786,11 @@ class ReadonlyTest(TestCase): formats.localize(datetime.date.today() - datetime.timedelta(days=7)) ) - self.assertContains(response, '
') - self.assertContains(response, '
') - self.assertContains(response, '
') - self.assertContains(response, '
') - self.assertContains(response, '
') + self.assertContains(response, '
') + self.assertContains(response, '
') + self.assertContains(response, '
') + self.assertContains(response, '
') + self.assertContains(response, '
') self.assertContains(response, '

', 3) self.assertContains(response, '

Some help text for the title (with unicode ŠĐĆŽćžšđ)

') self.assertContains(response, '

Some help text for the content (with unicode ŠĐĆŽćžšđ)

') @@ -2983,6 +2983,33 @@ class GroupAdminTest(TestCase): self.assertEqual(response.status_code, 200) +class CSSTest(TestCase): + urls = "regressiontests.admin_views.urls" + fixtures = ['admin-views-users.xml'] + + def setUp(self): + self.client.login(username='super', password='secret') + + def tearDown(self): + self.client.logout() + + def test_css_classes(self): + response = self.client.get('/test_admin/admin/admin_views/post/add/') + + # The main form + self.assertContains(response, 'class="form-row field-title"') + self.assertContains(response, 'class="form-row field-content"') + self.assertContains(response, 'class="form-row field-public"') + self.assertContains(response, 'class="form-row field-awesomeness_level"') + self.assertContains(response, 'class="form-row field-coolness"') + self.assertContains(response, 'class="form-row field-value"') + self.assertContains(response, 'class="form-row"') # The lambda function + + # The tabular inline + self.assertContains(response, '') + self.assertContains(response, '') + + try: import docutils except ImportError: