#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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019875fbf72f-eb0504ca-8ae8-4c70-afef-807227a3f52e-000000%40eu-central-1.amazonses.com.

Reply via email to