#34880 closed New feature (wontfix)
Required a post_save_action hook to perform additional action in admin.
Reported by: | AjmalPonneth | Owned by: | AjmalPonneth |
---|---|---|---|
Component: | contrib.admin | Version: | 4.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
We need to provide a post_save_action hook in ModelAdmin in order to perform additional actions after saving the object. This feature will be useful if we are sending webhooks, notifications, etc. Overriding ModelAdmin.save_model() is not possible if a m2m field is there.
def post_save_action(request, obj): """ Hook to perform an action after the 'Save' button has been pressed when adding a new object. """ pass ... self.save_model(request, new_object, form, not add) self.save_related(request, form, formsets, not add) self.post_save_action(request, new_object)
The method should call after the ModelAdmin.save_related() is completed.
Change History (2)
comment:1 by , 15 months ago
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
comment:2 by , 15 months ago
Also, post_save
signal already exists and we don't want to add redundant contrib
-specific signals.
Note:
See TracTickets
for help on using tickets.
Hi!
Feature requests require discussion on the Django Forum (https://code.djangoproject.com/wiki/DevelopersMailingList) first where more people will see the request and an appropriate discussion can be had. Having said that it's unlikely to be accepted as the admin isn't intended to be a universal app platform.
Also check out the signals to see whether this is appropriate for your needs: https://docs.djangoproject.com/en/4.2/ref/signals/#post-save
If you want further help on this, please seek help from one of our friendly communities: https://www.djangoproject.com/community/