Ticket #12952: django-admin-history-verbose-name.diff

File django-admin-history-verbose-name.diff, 1.8 KB (added by Alex Gaynor, 15 years ago)

Initial patch, probably needs tests.

  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 43a9984..34a42a8 100644
    a b class ModelAdmin(BaseModelAdmin):  
    553553        """
    554554        Construct a change message from a changed object.
    555555        """
     556        def convert_changed_list(obj, changed_data):
     557            cls = type(obj)
     558            verbose_names = []
     559            for field in changed_data:
     560                try:
     561                    verbose_names.append(cls._meta.get_field_by_name(field)[0].verbose_name)
     562                except FieldDoesNotExist:
     563                    verbose_names.append(field)
     564            return verbose_names
     565       
    556566        change_message = []
    557567        if form.changed_data:
    558             change_message.append(_('Changed %s.') % get_text_list(form.changed_data, _('and')))
     568            change_message.append(_('Changed %s.') %
     569                get_text_list(convert_changed_list(form.instance, form.changed_data), _('and')))
    559570
    560571        if formsets:
    561572            for formset in formsets:
    class ModelAdmin(BaseModelAdmin):  
    565576                                             'object': force_unicode(added_object)})
    566577                for changed_object, changed_fields in formset.changed_objects:
    567578                    change_message.append(_('Changed %(list)s for %(name)s "%(object)s".')
    568                                           % {'list': get_text_list(changed_fields, _('and')),
     579                                          % {'list': get_text_list(convert_changed_list(changed_object, changed_fields), _('and')),
    569580                                             'name': changed_object._meta.verbose_name,
    570581                                             'object': force_unicode(changed_object)})
    571582                for deleted_object in formset.deleted_objects:
Back to Top