Skip to content

Commit 7ea5089

Browse files
committed
added field_verbose_name to display when date_hierarchy is loaded
1 parent cb71904 commit 7ea5089

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

django/contrib/admin/templatetags/admin_list.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ def date_hierarchy(cl):
376376
if cl.date_hierarchy:
377377
field_name = cl.date_hierarchy
378378
field = get_fields_from_path(cl.model, field_name)[-1]
379+
field_verbose_name = field.verbose_name
379380
if isinstance(field, models.DateTimeField):
380381
dates_or_datetimes = "datetimes"
381382
else:
@@ -418,6 +419,7 @@ def link(filters):
418419
"choices": [
419420
{"title": capfirst(formats.date_format(day, "MONTH_DAY_FORMAT"))}
420421
],
422+
"field_name": field_verbose_name,
421423
}
422424
elif year_lookup and month_lookup:
423425
days = getattr(cl.queryset, dates_or_datetimes)(field_name, "day")
@@ -440,6 +442,7 @@ def link(filters):
440442
}
441443
for day in days
442444
],
445+
"field_name": field_verbose_name,
443446
}
444447
elif year_lookup:
445448
months = getattr(cl.queryset, dates_or_datetimes)(field_name, "month")
@@ -457,6 +460,7 @@ def link(filters):
457460
}
458461
for month in months
459462
],
463+
"field_name": field_verbose_name,
460464
}
461465
else:
462466
years = getattr(cl.queryset, dates_or_datetimes)(field_name, "year")
@@ -470,6 +474,7 @@ def link(filters):
470474
}
471475
for year in years
472476
],
477+
"field_name": field_verbose_name,
473478
}
474479

475480

0 commit comments

Comments
 (0)