Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#25465 closed Bug (fixed)

Line breaks in readonly field in admin tabular inline

Reported by: Patrick Craston Owned by: nobody
Component: contrib.admin Version: 1.8
Severity: Normal Keywords: tabular inline
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If a model TextField is rendered as read-only inside a included fieldset or an admin.TabularInline section, line breaks are ignored.

This is because of the changes made in https://github.com/django/django/commit/c94bff2b26f8844fe15d68a79511ff3a6853dc61 :
to these files:
django/contrib/admin/templates/admin/edit_inline/tabular.html
django/contrib/admin/templates/admin/includes/fieldset.html

Specifically the following code change in both files:

{% if field.is_readonly %}
-                  <p>{{ field.contents|linebreaksbr }}</p>
+                  <p>{{ field.contents }}</p>

The linebreaksbr template tag was removed but the django/contrib/admin/helpers.py:186 linebreaksbr function is only applied to custom ModelAdmin methods but not plain admin fields

Am I missing something or is this a bug?

Change History (11)

comment:1 Changed 4 years ago by Tim Graham

Triage Stage: UnreviewedAccepted

It seems this was probably an oversight.

comment:3 Changed 4 years ago by Sasha Gaevsky

Has patch: set
Version: 1.8master

comment:4 Changed 4 years ago by Tim Graham

Needs tests: set
Patch needs improvement: set

comment:5 Changed 4 years ago by Tim Graham

The ticket "Version" field is the version the ticket is reported in and generally doesn't need to be updated to "master" (if the issue is no longer relevant on master, then the ticket is can usually be closed). If this is a regression in 1.8, then it qualifies for a backport.

comment:6 in reply to:  5 Changed 4 years ago by Sasha Gaevsky

Replying to timgraham:

The ticket "Version" field is the version the ticket is reported in and generally doesn't need to be updated to "master" (if the issue is no longer relevant on master, then the ticket is can usually be closed).

Ok, thanks for the info, will consider in the future.

If this is a regression in 1.8, then it qualifies for a backport.

Yes, it's a regression, but appeared to be in 1.7 - it still worked in 1.6.11.

Last edited 4 years ago by Sasha Gaevsky (previous) (diff)

comment:7 Changed 4 years ago by Tim Graham

Needs tests: unset
Patch needs improvement: unset

comment:8 Changed 4 years ago by Tim Graham

Triage Stage: AcceptedReady for checkin
Version: master1.8

comment:9 Changed 4 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In 69208a5:

Fixed #25465 -- Restored line breaks conversion in admin readonly fields.

comment:10 Changed 4 years ago by Tim Graham <timograham@…>

In 312e488:

[1.9.x] Fixed #25465 -- Restored line breaks conversion in admin readonly fields.

Backport of 69208a5a1c55d42ca0eaffa900be643d9f801089 from master

comment:11 Changed 4 years ago by Tim Graham <timograham@…>

In 83174866:

[1.8.x] Fixed #25465 -- Restored line breaks conversion in admin readonly fields.

Backport of 69208a5a1c55d42ca0eaffa900be643d9f801089 from master

Note: See TracTickets for help on using tickets.
Back to Top