**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.
--
Ticket URL: <https://code.djangoproject.com/ticket/33946>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Alex Morega):
In your example you're setting `verbose_name` on the `myfield` field. It
looks like it's meant to be a string; the
[https://docs.djangoproject.com/en/4.1/topics/db/models/#verbose-field-
names Verbose field names] documentation implies that.
>In other words, change_list.html handles this case well.
That's probably accidental. If you want a custom field label in the admin
change form, you're better off customizing the
[https://docs.djangoproject.com/en/4.1/ref/contrib/admin/#django.contrib.admin.ModelAdmin.form
ModelAdmin.form]:
{{{#!python
from django.contrib import admin
from django.forms.models import ModelForm
class MyModelForm(ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['myfield'].label = format_html(
'<i class="fa-regular fa-hourglass-half"></i>'
)
@admin.register(models.MyModel)
class MyModelAdmin(admin.ModelAdmin):
form = MyModelForm
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33946#comment:1>
* status: new => closed
* resolution: => invalid
Comment:
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/33946#comment:2>