#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)
Change History (14)
by , 15 years ago
Attachment: | modelAdmin_model_modified_hook.diff added |
---|
comment:1 by , 15 years ago
comment:2 by , 15 years ago
The has_changed hook doesn't look like it triggers on the delete of a record.
by , 15 years ago
Attachment: | modelAdmin_model_modified_hook.2.diff added |
---|
Added hook to the changelist_view() bulk update
comment:3 by , 15 years ago
milestone: | → 1.2 |
---|
comment:4 by , 15 years ago
Needs documentation: | set |
---|---|
Needs tests: | set |
Triage Stage: | Unreviewed → Design decision needed |
comment:5 by , 15 years ago
milestone: | 1.2 |
---|
1.2 is feature-frozen, moving this feature request off the milestone.
comment:6 by , 14 years ago
Cc: | 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:8 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:11 by , 12 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
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.
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.