Skip to content

Fixed #36367 -- Improving the accessibility of the date_hierarchy layout in the admin. #19688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
added field_verbose_name to display when date_hierarchy is loaded
  • Loading branch information
XChaitanyaX committed Jul 31, 2025
commit 7ea50897488f06c29f3dc2aafaf5f0e22dbc105f
5 changes: 5 additions & 0 deletions django/contrib/admin/templatetags/admin_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ def date_hierarchy(cl):
if cl.date_hierarchy:
field_name = cl.date_hierarchy
field = get_fields_from_path(cl.model, field_name)[-1]
field_verbose_name = field.verbose_name
if isinstance(field, models.DateTimeField):
dates_or_datetimes = "datetimes"
else:
Expand Down Expand Up @@ -418,6 +419,7 @@ def link(filters):
"choices": [
{"title": capfirst(formats.date_format(day, "MONTH_DAY_FORMAT"))}
],
"field_name": field_verbose_name,
}
elif year_lookup and month_lookup:
days = getattr(cl.queryset, dates_or_datetimes)(field_name, "day")
Expand All @@ -440,6 +442,7 @@ def link(filters):
}
for day in days
],
"field_name": field_verbose_name,
}
elif year_lookup:
months = getattr(cl.queryset, dates_or_datetimes)(field_name, "month")
Expand All @@ -457,6 +460,7 @@ def link(filters):
}
for month in months
],
"field_name": field_verbose_name,
}
else:
years = getattr(cl.queryset, dates_or_datetimes)(field_name, "year")
Expand All @@ -470,6 +474,7 @@ def link(filters):
}
for year in years
],
"field_name": field_verbose_name,
}


Expand Down