diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 7f95801..abd9582 100644
a
|
b
|
class ModelAdmin(BaseModelAdmin):
|
408 | 408 | |
409 | 409 | `formsets` is a sequence of InlineFormSet instances that are verified to be valid. |
410 | 410 | """ |
| 411 | def diff(obj, dict_): |
| 412 | added, changed, removed = [], [], [] |
| 413 | fields = [f.name for f in obj._meta.fields] |
| 414 | for key in dict_.keys(): |
| 415 | if key in fields: |
| 416 | if dict_[key] is None and getattr(obj, key) is not None: |
| 417 | removed.append(key) |
| 418 | elif dict_[key] is not None and getattr(obj, key) is None: |
| 419 | added.append(key) |
| 420 | elif dict_[key] != getattr(obj, key): |
| 421 | changed.append(key) |
| 422 | return added, changed, removed |
| 423 | |
411 | 424 | from django.contrib.admin.models import LogEntry, CHANGE |
412 | 425 | from django.contrib.contenttypes.models import ContentType |
413 | 426 | opts = model._meta |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
417 | 430 | if formsets: |
418 | 431 | for formset in formsets: |
419 | 432 | formset.save() |
420 | | |
| 433 | added, changed, removed = diff(new_object, form.cleaned_data) |
421 | 434 | # Construct the change message. TODO: Temporarily commented-out, |
422 | 435 | # as manipulator object doesn't exist anymore, and we don't yet |
423 | 436 | # have a way to get fields_added, fields_changed, fields_deleted. |
424 | 437 | change_message = [] |
425 | | #if manipulator.fields_added: |
426 | | #change_message.append(_('Added %s.') % get_text_list(manipulator.fields_added, _('and'))) |
427 | | #if manipulator.fields_changed: |
428 | | #change_message.append(_('Changed %s.') % get_text_list(manipulator.fields_changed, _('and'))) |
429 | | #if manipulator.fields_deleted: |
430 | | #change_message.append(_('Deleted %s.') % get_text_list(manipulator.fields_deleted, _('and'))) |
431 | | #change_message = ' '.join(change_message) |
| 438 | if added: |
| 439 | change_message.append(_('Added %s.') % ' and '.join(added)) |
| 440 | if changed: |
| 441 | change_message.append(_('Changed %s.') % ' and '.join(changed)) |
| 442 | if removed: |
| 443 | change_message.append(_('Deleted %s.') % ' and '.join(removed)) |
| 444 | change_message = ' '.join(change_message) |
432 | 445 | if not change_message: |
433 | 446 | change_message = _('No fields changed.') |
434 | 447 | LogEntry.objects.log_action(request.user.id, ContentType.objects.get_for_model(model).id, pk_value, force_unicode(new_object), CHANGE, change_message) |