Skip to content

Commit

Permalink
[1.5.x] Fixed #19429 -- Applied linebreaksbr to read-only fields in i…
Browse files Browse the repository at this point in the history
…nlines

Applied to inlines what ec9d6b1 did for main fieldsets.
Backport of 553838a from master.
  • Loading branch information
Marc Aymerich authored and claudep committed Dec 6, 2012
1 parent a8045c3 commit 57a41d9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Expand Up @@ -46,7 +46,7 @@ <h2>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h2>
{% for field in line %}
<td{% if field.field.name %} class="field-{{ field.field.name }}"{% endif %}>
{% if field.is_readonly %}
<p>{{ field.contents }}</p>
<p>{{ field.contents|linebreaksbr }}</p>
{% else %}
{{ field.field.errors.as_ul }}
{{ field.field }}
Expand Down
5 changes: 4 additions & 1 deletion tests/regressiontests/admin_views/admin.py
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions tests/regressiontests/admin_views/tests.py
Expand Up @@ -3164,6 +3164,7 @@ def test_readonly_get(self):

# Checks that multiline text in a readonly field gets <br /> tags
self.assertContains(response, "Multiline<br />test<br />string")
self.assertContains(response, "InlineMultiline<br />test<br />string")

self.assertContains(response,
formats.localize(datetime.date.today() - datetime.timedelta(days=7))
Expand Down

0 comments on commit 57a41d9

Please sign in to comment.