[Django] #36772: `aria-describedby`-Attribute missing from file field HTML in Django 6.0

4 views
Skip to first unread message

Django

unread,
Dec 4, 2025, 6:30:48 AM (yesterday) Dec 4
to django-...@googlegroups.com
#36772: `aria-describedby`-Attribute missing from file field HTML in Django 6.0
-------------------------------------+-------------------------------------
Reporter: cessor | Type: Bug
Status: new | Component: Forms
Version: 6.0 | Severity: Normal
Keywords: forms, aria, | Triage Stage:
fieldset, accessibility, admin | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
In Django 6, input fields of type `file` do not render `aria-describedby`
attributes. Those were introduced with Django 5.2. to facilitate use of
screenreaders.

== Steps to reproduce

- Create a model with a `file = models.FileField(...)`
- Render a `forms.ModelForm` for the model
- The HTML for the input field should contain attribute `aria-
describedby="id_file_helptext"`
- When Django 5.2 is installed the attribute is rendered
- When Django 6.0 is installed, the attribute is not rendered

Note that this issue affects `FileFields` but not `CharFields`. Both
render HTML input elements. I did not test whether other fields are also
affected.

I attached a zipfile with an example app. To reproduce the error, please
create a .venv and install Django 5.2, then run `manage.py tests`; all
will succeed. When installing Django 6, one test will fail. The module
`web.tests` contains two tests, both check the input field HTML for `aria-
describedby`, one is for a charfield, the other for a filefield.


== Details

Consider Issue #35892 "Supported Widget.use_fieldset in admin forms.". In
the scope of this ticked, a change was made to
`django.forms.widgets.ClearableFileInput`, where as with commit 4187da2
the value `ClearableFileInput.use_fieldset` is set to `True` by default.

Because of this change,
`django.forms.boundfield.BoundField.build_widget_attrs` does not add the
"aria-describedby" attribute to the `attrs` dictionary which is then
missing from the final response HTML.

Sources:
-
https://github.com/django/django/blame/0ca3a0661173b02e2cbb0183d8543e790e7e4a55/django/forms/widgets.py#L533
-
https://github.com/django/django/blob/0ca3a0661173b02e2cbb0183d8543e790e7e4a55/django/forms/boundfield.py#L300
--
Ticket URL: <https://code.djangoproject.com/ticket/36772>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 4, 2025, 6:31:03 AM (yesterday) Dec 4
to django-...@googlegroups.com
#36772: `aria-describedby`-Attribute missing from file field HTML in Django 6.0
-------------------------------------+-------------------------------------
Reporter: cessor | Owner: (none)
Type: Bug | Status: new
Component: Forms | Version: 6.0
Severity: Normal | Resolution:
Keywords: forms, aria, | Triage Stage:
fieldset, accessibility, admin | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by cessor):

* Attachment "aria.7z" added.

Django

unread,
Dec 4, 2025, 11:14:10 AM (yesterday) Dec 4
to django-...@googlegroups.com
#36772: `aria-describedby`-Attribute missing from file field HTML in Django 6.0
-------------------------------------+-------------------------------------
Reporter: cessor | Owner: (none)
Type: Bug | Status: closed
Component: Forms | Version: 6.0
Severity: Normal | Resolution: invalid
Keywords: forms, aria, | Triage Stage:
fieldset, accessibility, admin | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

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

Comment:

Thanks for the test project. I noticed your test manually renders input
fields instead of directly rendering the form. When a `<fieldset>` is in
play, it's expected that the aria attribute will be on the `<fieldset>`,
not the `<input>`, which is what's happening:


{{{#!py
In [1]: from django.forms import *

In [2]: class UploadForm(ModelForm):
...: class Meta:
...: model = Upload
...: fields = ["file"]
...:

In [3]: from pprint import pprint

In [4]: pprint(UploadForm().as_div())
('<div>\n'
' <fieldset aria-describedby="id_file_helptext">\n'
' <legend>CSV-File:</legend>\n'
'\n'
'<div class="helptext" id="id_file_helptext">File containing comma
separated '
'values.</div>\n'
'\n'
'<input type="file" name="file" required id="id_file"></fieldset>\n'
' \n'
' \n'
' \n'
'</div>')
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36772#comment:1>
Reply all
Reply to author
Forward
0 new messages