#30577: feature request: custom rendering for readonly fields in admin
-----------------------------------------+------------------------
Reporter: David | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
The new view permission is extremely useful, and encourages more use of
the Django Admin tool. It has highlighted a limitation in the rendering of
`readonly_fields` that can be easily addressed. At the moment,
`readonly_fields` (or all fields when the user has only `can_view`) can
only have custom rendering or formatting if they are custom properties or
new fields (created in the ModelAdmin), existing fields can't be changed.
In my use-case I have a number of rich text enhanced `TextField`s, which
when rendered as read-only show up as HTML and can't be marked safe. In
this case creating a custom field in the `ModelAdmin` where the Field can
be output with `mark_safe()` doesn't work as the original field needs to
exist for users with change permissions, the only other way is to include
the field twice which creates UX issues.
If, in ModelAdmin, you could override the formatting/output of a read-only
field it would address this issue. Alternatively, as mentioned in the
comments of #14802, the idea of Fields having a method that is called by
admin to handle the read-only HTML rendering would also do the trick as is
related.
--
Ticket URL: <https://code.djangoproject.com/ticket/30577>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/049.37e291a797513ee680ad2f9c741c9341%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.