Django

Code

Ticket #11772 (new)

Opened 6 months ago

Last modified 2 months ago

ModelAdmin - added a model_modified hook for full CRUD support

Reported by: Rupe Assigned to: nobody
Milestone: 1.2 Component: django.contrib.admin
Version: SVN Keywords: modeladmin hook modified save add change delete
Cc: Triage Stage: Design decision needed
Has patch: 1 Needs documentation: 1
Needs tests: 1 Patch needs improvement: 0

Description

I added a simple hook called model_modified that is called after each insert, update, and delete via the ModelAdmin? class. There are times when it's useful to know when a model changes in any way by the user (via the admin app), including delete. The current methodology of overriding the save_model hook does not include delete. The usefulness of this hook over using the model signals for model changes is that you have access to the response object. I used this hook to clear certain session variables that were dependent on the correlating models.

Attachments

modelAdmin_model_modified_hook.diff (1.8 kB) - added by Rupe on 08/23/09 05:32:03.
modelAdmin_model_modified_hook.2.diff (2.2 kB) - added by Rupe on 09/11/09 09:41:13.
Added hook to the changelist_view() bulk update

Change History

08/23/09 05:32:03 changed by Rupe

  • attachment modelAdmin_model_modified_hook.diff added.

08/23/09 08:00:32 changed by Mnewman

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

Can you clear up for me why you need a hook here? You have access to model.form.has_changed() in any other hook on the modeladmin, and this looks like overkill for me. Maybe I am missing something.

08/23/09 13:08:26 changed by Rupe

The has_changed hook doesn't look like it triggers on the delete of a record.

09/11/09 09:41:13 changed by Rupe

  • attachment modelAdmin_model_modified_hook.2.diff added.

Added hook to the changelist_view() bulk update

10/10/09 14:20:29 changed by Rupe

  • milestone set to 1.2.

12/13/09 11:34:40 changed by tobias

  • needs_docs set to 1.
  • needs_tests set to 1.
  • stage changed from Unreviewed to Design decision needed.

Add/Change #11772 (ModelAdmin - added a model_modified hook for full CRUD support)




Change Properties
Action