﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35439	Hardcoded HTML in python code.	sesostris	nobody	"There is a hardcoded snippet of HTML in the django.contrib.admin.templatetags.admin_list module on lines 99 to 110 that will be used in the header of the changelist results table.

https://github.com/django/django/blob/0e445badd54fafc75dd1a5dff9fee6e6a171eafe/django/contrib/admin/templatetags/admin_list.py#L99C1-L110C25

{{{
            # if the field is the action checkbox: no sorting and special class
            if field_name == ""action_checkbox"":
                aria_label = _(""Select all objects on this page for an action"")
                yield {
                    ""text"": mark_safe(
                        f'<input type=""checkbox"" id=""action-toggle"" '
                        f'aria-label=""{aria_label}"">'
                    ),
                    ""class_attrib"": mark_safe(' class=""action-checkbox-column""'),
                    ""sortable"": False,
                }
                continue
}}}

It would be better to use a CheckboxInput widget to render this HTML element. The code would look like this:

{{{
from django.forms import CheckboxInput

        # if the field is the action checkbox: no sorting and special class
        if field_name == ""action_checkbox"":
            widget = CheckboxInput(
                attrs={
                    ""aria-label"": _(
                        ""Select all objects on this page for an action""
                    ),
                    ""id"": ""action-toggle"",
                }
            )
            yield {
                ""text"": mark_safe(
                    widget.render(name=""action-toggle"", value=False)
                ),
                ""class_attrib"": mark_safe(' class=""action-checkbox-column""'),
                ""sortable"": False,
            }
            continue
}}}"	Cleanup/optimization	closed	contrib.admin	5.0	Normal	wontfix			Unreviewed	0	0	0	0	0	0
