Opened 2 years ago
Closed 2 years ago
#33946 closed Bug (invalid)
admin change_form field label does not use mark_safe
Reported by: | Caram | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 4.1 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | yes |
Description
Example:
models.py
myfield = models.BooleanField(format_html('<i class="fa-regular fa-hourglass-half"</i>'))
generated HTML
<label class="vCheckboxLabel" for="id_myfield"><i class="fa-regular fa-hourglass-half"></i></label>
The issue only occurs for change_form.html. In other words, change_list.html handles this case well.
Change History (2)
comment:1 by , 2 years ago
comment:2 by , 2 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
The issue tracker is for bug reports on Django, not support requests. Please see TicketClosingReasons/UseSupportChannels for appropriate places for questions like this. (It's always possible to open a ticket if it turns out to be a bug.)
Also, Caram, please do not post to the DevelopersMailingList saying you've opened a ticket here. That just spams a whole lot of people.
Thanks.
In your example you're setting
verbose_name
on themyfield
field. It looks like it's meant to be a string; the Verbose field names documentation implies that.That's probably accidental. If you want a custom field label in the admin change form, you're better off customizing the ModelAdmin.form: