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