diff --git a/django/contrib/admin/templates/admin/edit_inline/tabular.html b/django/contrib/admin/templates/admin/edit_inline/tabular.html index f2757ede488..71a62ba71a6 100644 --- a/django/contrib/admin/templates/admin/edit_inline/tabular.html +++ b/django/contrib/admin/templates/admin/edit_inline/tabular.html @@ -46,7 +46,7 @@ {% for field in line %} {% if field.is_readonly %} -

{{ field.contents }}

+

{{ field.contents|linebreaksbr }}

{% else %} {{ field.field.errors.as_ul }} {{ field.field }} diff --git a/tests/regressiontests/admin_views/admin.py b/tests/regressiontests/admin_views/admin.py index d71c3983763..1e4e9b5c75e 100644 --- a/tests/regressiontests/admin_views/admin.py +++ b/tests/regressiontests/admin_views/admin.py @@ -346,7 +346,10 @@ class LinkInline(admin.TabularInline): model = Link extra = 1 - readonly_fields = ("posted",) + readonly_fields = ("posted", "multiline") + + def multiline(self, instance): + return "InlineMultiline\ntest\nstring" class SubPostInline(admin.TabularInline): diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py index bbb8281fed4..10f946132d3 100644 --- a/tests/regressiontests/admin_views/tests.py +++ b/tests/regressiontests/admin_views/tests.py @@ -3164,6 +3164,7 @@ class ReadonlyTest(TestCase): # Checks that multiline text in a readonly field gets
tags self.assertContains(response, "Multiline
test
string") + self.assertContains(response, "InlineMultiline
test
string") self.assertContains(response, formats.localize(datetime.date.today() - datetime.timedelta(days=7))