#36884: Translation of admin log messages fails due to case inconsistency in 
field
names
-------------------------------+------------------------------------------
     Reporter:  Meiyer         |                    Owner:  Thrishagowdabl
         Type:  Bug            |                   Status:  assigned
    Component:  contrib.admin  |                  Version:  3.0
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Accepted
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  1
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+------------------------------------------
Comment (by master):

 Here is a proposed patch of `contrib/admin/utils.py`:

 {{{
 --- C:/D/tmp/utils_old.py       Tue Feb 10 11:20:50 2026
 +++ C:/D/tmp/utils_new.py       Tue Feb 10 11:21:01 2026
 @@ -1,8 +1,10 @@
  def _get_changed_field_labels_from_form(form, changed_data):
      changed_field_labels = []
 +    opts = form.instance._meta
      for field_name in changed_data:
          try:
 -            verbose_field_name = form.fields[field_name].label or
 field_name
 +            # can't use form.fields[field_name].label because it is
 wrapped in capfirst()
 +            verbose_field_name = opts.get_field(field_name).verbose_name
 or field_name
          except KeyError:
              verbose_field_name = field_name
          changed_field_labels.append(str(verbose_field_name))
 }}}

 Now, my example is:
 column content: `[{"changed": {"fields": ["status"]}}]`
 str of logentry: `Modification de « t2>t2:90 » — Modification de état.`
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36884#comment:7>
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/0107019c4721e33d-f0120810-77a9-41ba-83ab-46888d8e91b7-000000%40eu-central-1.amazonses.com.

Reply via email to