Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#22241 closed Bug (fixed)

Extra line break tags in contrib/admin/templates/admin/includes/fieldset.html break display of computed fields

Reported by: atodorov@… Owned by: nobody
Component: contrib.admin Version: 1.6
Severity: Normal Keywords:
Cc: atodorov@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This is a reference to #19226 which is not properly fixed.

See:
https://code.djangoproject.com/ticket/19226#comment:14

<quote>
Hi guys,
this fix is breaking up display for me. I'm using computed read-only fields which display rich HTML into the model change form as a way to augment the administration experience which works really well for me.

Adding multiple line break tags breaks my display (this only happens because the templates used to render the fields have new lines in them). Now I have to go all-over my code and strip new lines before returning the field value.

It would be nice if the linebreaks filter skipped \n, <br/> replacement on safe strings.
</quote>

Attached is code to reproduce. Run it on Django 1.4.X and then on 1.5.X or 1.6.X to see the difference.

In the add/change form for Advisory objects there are several divs which should appear on the same line but with the added line breaks they get messed up.

Workaround is to remove all newlines before rendering this field value.

Initially the bug was reported against text area type of fields so either fix it only for them or allow linebreaksbr filter to skip safe strings.

Attachments (4)

bugtest.tar.gz (1.8 KB ) - added by atodorov@… 10 years ago.
Small project to reproduce the issue
django_1.4.png (22.3 KB ) - added by atodorov@… 10 years ago.
Screenshot with Django 1.4.X
django_1.6.png (25.2 KB ) - added by atodorov@… 10 years ago.
Screenshot with Django 1.6.X
22241-1.diff (4.4 KB ) - added by Claude Paroz 10 years ago.
Initial patch to fix this issue

Download all attachments as: .zip

Change History (7)

by atodorov@…, 10 years ago

Attachment: bugtest.tar.gz added

Small project to reproduce the issue

by atodorov@…, 10 years ago

Attachment: django_1.4.png added

Screenshot with Django 1.4.X

by atodorov@…, 10 years ago

Attachment: django_1.6.png added

Screenshot with Django 1.6.X

comment:1 by Claude Paroz, 10 years ago

Component: Template systemcontrib.admin
Has patch: set
Triage Stage: UnreviewedAccepted

Thanks for the code and screenshots, this is helpful.

I'll upload a patch for this issue. Please review/test.

by Claude Paroz, 10 years ago

Attachment: 22241-1.diff added

Initial patch to fix this issue

comment:2 by Claude Paroz <claude@…>, 10 years ago

Resolution: fixed
Status: newclosed

In c94bff2b26f8844fe15d68a79511ff3a6853dc61:

Fixed #22241 -- Selectively added line breaks in admin read-only fields

When content is supposed to contain HTML, we do not try to add
line breaks in read-only contents.
Thanks Alexander Todorov for the report.

comment:3 by Claude Paroz <claude@…>, 10 years ago

In d345a030c2f3b332512e5091248dd8b06e859eac:

[1.7.x] Fixed #22241 -- Selectively added line breaks in admin read-only fields

When content is supposed to contain HTML, we do not try to add
line breaks in read-only contents.
Thanks Alexander Todorov for the report.
Backport of c94bff2 from master.

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