#36539: Label for related fields should use related model verbose_name attribute
for field
-------------------------------------+-------------------------------------
Reporter: Leandro de Souza | Type:
| Uncategorized
Status: new | Component:
| contrib.admin
Version: 5.2 | Severity: Normal
Keywords: list_display, | Triage Stage:
fieldsets | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Django 5.1 has added support for referencing related fields directly from
the list_display/fieldsets option on the
django.contrib.admin.options.ModelAdmin class (#10743).
However, when referencing this field, the label generated for this field
is using the attribute name instead of the verbose_name defined on that
field.
Using the verbose_name would make much more sense and would be a great
addition.
Example:
{{{
# books/models.py
from django.db import models
class Author(models.Model):
name = models.CharField(verbose_name="Name of the author")
class Book(models.Model):
author = models.ForeignKey(to=Author, on_delete=models.PROTECT)
# books/admin.py
from django.contrib import admin
from .models import Book
@admin.register(Book)
class BookAdmin(admin.ModelAdmin):
list_display = ("author__name",)
}}}
The above code would display on the change_list page: "Author name"
instead of the verbose_name defined at the `
author.name` field.
The same applies to fieldsets used on the change page.
--
Ticket URL: <
https://code.djangoproject.com/ticket/36539>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.