Opened 9 years ago

Closed 9 years ago

#24990 closed Bug (duplicate)

Admin Log change message display changed fields names (not label text nor fields' verbose names )

Reported by: Ramez Issac Owned by: nobody
Component: contrib.admin Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

When an object is edited from the admin, ModelAdmin.construct_change_message() report the changed fields by their form's name instead of their label value or even field verbose name.

This 'might be ok' only if the field names are equal to label text and in English
If the active language is not English, change message looks wired like this:
عدل name (i.e. changed name)

You can see the cause of the issue here
https://github.com/django/django/blob/master/django/contrib/admin/options.py#L925-L926
And again with formsets 936
https://github.com/django/django/blob/master/django/contrib/admin/options.py#L936

Not sure how to write a test for this .

My Proposed Fix:
Instead of sending form.changed_data to get_text_list, send their labels

translated_changed_fields = [form.fields[f].label for f in form.changed_data]
change_message.append(_('Changed %s.') % get_text_list(translated_changed_fields, _('and')))

And again with formset

        translated_changed_fields = [formset.fields[f].label for f in changed_fields]
        #...
            % {'list': get_text_list(translated_changed_fields, _('and')), 

Regards;

Change History (1)

comment:1 by Tim Graham, 9 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #12952

Note: See TracTickets for help on using tickets.
Back to Top