Opened 8 years ago

Last modified 7 years ago

#27386 closed Cleanup/optimization

Callable field is wrapped inside <p>...</p> — at Initial Version

Reported by: Jacob Rief Owned by: nobody
Component: contrib.admin Version: dev
Severity: Normal Keywords: callable field is_readonly <p>
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

(Pseudo)-Fields in classes inheriting from django.contrib.admin.ModelsAdmin which are callables, must be listed in readonly_fields. This implies that in admin/includes/fieldset.html (line 17) and admin/edit_inline/tabular.html (line 55) the content of this field is wrapped inside a paragraph <p>{{ field.contents }}</p>.

However, a <p>...</p> is not suitable to accept every kind of HTML element. Therefore when using a "callable" field, which renders it's content in HTML, one might get a surprising result.

Since the author of a callable field may wrap it's content into whatever (s)he likes, there should be a way to avoid these wrapping paragraphs.

My proposal is to check if field.contents is safe text, and if so then leave it as-is, or otherwise wrap it into <p>..</p> as we do it right now.

Change History (0)

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