[Django] #36359: id_for_label undefined for AdminReadonlyField

2 views
Skip to first unread message

Django

unread,
Apr 29, 2025, 9:07:39 AM4/29/25
to django-...@googlegroups.com
#36359: id_for_label undefined for AdminReadonlyField
-------------------------------------+-------------------------------------
Reporter: Marc Sommerhalder | Type: Bug
Status: new | Component:
| contrib.admin
Version: 5.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
-------------------------------------+-------------------------------------
AdminReadonlyField does not define `id_for_label`
([https://github.com/django/django/blob/65bbdbd10b25700d1166b1a698e672a4695281bc/django/contrib/admin/helpers.py#L225
here]) but uses it when `help_text` is present
([https://github.com/django/django/blob/65bbdbd10b25700d1166b1a698e672a4695281bc/django/contrib/admin/templates/admin/includes/fieldset.html#L29
here]).
--
Ticket URL: <https://code.djangoproject.com/ticket/36359>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 29, 2025, 1:29:16 PM4/29/25
to django-...@googlegroups.com
#36359: id_for_label undefined for AdminReadonlyField
-----------------------------------+--------------------------------------
Reporter: Marc Sommerhalder | Owner: (none)
Type: Bug | Status: closed
Component: contrib.admin | Version: 5.2
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by Natalia Bidart):

* resolution: => invalid
* status: new => closed

Comment:

Hello Marc Sommerhalder, thanks for taking the time to report this and for
referencing the relevant code.

You're correct that `AdminReadonlyField` does not define `id_for_label`.
However, from what I can see, it's only accessed conditionally (i.e. only
if it's already defined) so there doesn’t appear to be any resulting error
or broken behavior in the admin output:
{{{
{% if field.field.id_for_label %} id="{{ field.field.id_for_label
}}_helptext"{% endif %}
}}}

To better understand the problem you're experiencing, could you clarify
what concrete issue you're observing in practice? For example, is there a
traceback, rendering problem, or integration issue that this is causing?
That would help determine whether this needs a code change or if the
current behavior is acceptable.

I'll close as `invalid` for now but please reopen if you can provide
further details (ideally a test case failing or a small Django test
project to reproduce the error or the issue you are getting). You can also
reach out in the Django Forum for further assistance
--
Ticket URL: <https://code.djangoproject.com/ticket/36359#comment:1>
Reply all
Reply to author
Forward
0 new messages