Opened 15 years ago

Closed 12 years ago

Last modified 12 years ago

#11772 closed New feature (wontfix)

ModelAdmin - added a model_modified hook for full CRUD support

Reported by: Joshua Russo Owned by: nobody
Component: contrib.admin Version: dev
Severity: Normal Keywords: modeladmin hook modified save add change delete
Cc: mmitar@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

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 (2)

modelAdmin_model_modified_hook.diff (1.8 KB ) - added by Joshua Russo 15 years ago.
modelAdmin_model_modified_hook.2.diff (2.2 KB ) - added by Joshua Russo 15 years ago.
Added hook to the changelist_view() bulk update

Download all attachments as: .zip

Change History (14)

by Joshua Russo, 15 years ago

comment:1 by Michael Newman, 15 years ago

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.

comment:2 by Joshua Russo, 15 years ago

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

by Joshua Russo, 15 years ago

Added hook to the changelist_view() bulk update

comment:3 by Joshua Russo, 15 years ago

milestone: 1.2

comment:4 by Tobias McNulty, 15 years ago

Needs documentation: set
Needs tests: set
Triage Stage: UnreviewedDesign decision needed

comment:5 by James Bennett, 15 years ago

milestone: 1.2

1.2 is feature-frozen, moving this feature request off the milestone.

comment:6 by Mitar, 14 years ago

Cc: mmitar@… added

I think we should go for signals here. There is no need to have some new hooks. If there is a wish for changing the response it can always be passed as an argument. Or a sender can be an admin object itself.

In this way it is not necessary to subclass the admin class.

comment:7 by Joshua Russo, 14 years ago

I'm ok with that. I'll do up the changes.

comment:8 by Julien Phalip, 14 years ago

Severity: Normal
Type: New feature

comment:9 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:10 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:11 by Aymeric Augustin, 12 years ago

Resolution: wontfix
Status: newclosed

model_modified duplicates existing functionality for hooking on model changes; I don't like that.

This is really a feature request, please take it to django-developers and try to get consensus on a better way of achieving this goal.

comment:12 by Mitar, 12 years ago

What about my proposal about signals?

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