Changes between Initial Version and Version 3 of Ticket #27386


Ignore:
Timestamp:
Oct 25, 2016, 5:36:19 PM (8 years ago)
Author:
Tim Graham
Comment:

I'm not sure if the proposal is completely backwards-compatible, but the problem seems real.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #27386

    • Property Keywords callable is_readonly <p> added
    • Property Triage Stage UnreviewedAccepted
    • Property Summary Callable field is wrapped inside <p>...</p>Readonly callable field is unconditionally wrapped inside <p>...</p>, which might create invalid HTML
  • Ticket #27386 – Description

    initial v3  
    1 (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>``.
     1(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>`.
    22
    3 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.
     3However, 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.
    44
    55Since 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.
    66
    7 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.
     7My 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.
Back to Top