diff --git a/django/contrib/admin/templates/admin/includes/fieldset.html b/django/contrib/admin/templates/admin/includes/fieldset.html index c8d08c880f..09bc971d2f 100644 --- a/django/contrib/admin/templates/admin/includes/fieldset.html +++ b/django/contrib/admin/templates/admin/includes/fieldset.html @@ -14,7 +14,7 @@ {% else %} {{ field.label_tag }} {% if field.is_readonly %} -

{{ field.contents }}

+

{{ field.contents|linebreaksbr }}

{% else %} {{ field.field }} {% endif %} diff --git a/tests/regressiontests/admin_views/admin.py b/tests/regressiontests/admin_views/admin.py index a5476e9eb7..6bb6ba59b0 100644 --- a/tests/regressiontests/admin_views/admin.py +++ b/tests/regressiontests/admin_views/admin.py @@ -388,7 +388,10 @@ class PrePopulatedPostAdmin(admin.ModelAdmin): class PostAdmin(admin.ModelAdmin): list_display = ['title', 'public'] - readonly_fields = ('posted', 'awesomeness_level', 'coolness', 'value', lambda obj: "foo") + readonly_fields = ( + 'posted', 'awesomeness_level', 'coolness', 'value', 'multiline', + lambda obj: "foo" + ) inlines = [ LinkInline @@ -402,6 +405,10 @@ class PostAdmin(admin.ModelAdmin): def value(self, instance): return 1000 + + def multiline(self, instance): + return "Multiline\ntest\nstring" + value.short_description = 'Value in $US' diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py index 72dc6a3f97..b5e0f407e5 100644 --- a/tests/regressiontests/admin_views/tests.py +++ b/tests/regressiontests/admin_views/tests.py @@ -3149,6 +3149,10 @@ class ReadonlyTest(TestCase): self.assertContains(response, "Very awesome.") self.assertContains(response, "Unkown coolness.") self.assertContains(response, "foo") + + # Checks that multiline text in a readonly field gets
tags + self.assertContains(response, "Multiline
test
string") + self.assertContains(response, formats.localize(datetime.date.today() - datetime.timedelta(days=7)) )