[Django] #34880: Required a post_save_action hook to perform additional action in admin.

5 views
Skip to first unread message

Django

unread,
Sep 28, 2023, 5:11:03 AM9/28/23
to django-...@googlegroups.com
#34880: Required a post_save_action hook to perform additional action in admin.
-----------------------------------------+------------------------------
Reporter: AjmalPonneth | Owner: AjmalPonneth
Type: New feature | Status: assigned
Component: contrib.admin | Version: 4.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-----------------------------------------+------------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/34880>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 28, 2023, 5:18:46 AM9/28/23
to django-...@googlegroups.com
#34880: Required a post_save_action hook to perform additional action in admin.
-------------------------------+----------------------------------------
Reporter: AjmalPonneth | Owner: AjmalPonneth
Type: New feature | Status: closed
Component: contrib.admin | Version: 4.2
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+----------------------------------------
Changes (by David Sanders):

* status: assigned => closed
* resolution: => wontfix


Comment:

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://code.djangoproject.com/wiki/DevelopersMailingList

If you want further help on this, please seek help from one of our
friendly communities: https://www.djangoproject.com/community/

--
Ticket URL: <https://code.djangoproject.com/ticket/34880#comment:1>

Django

unread,
Sep 28, 2023, 5:35:14 AM9/28/23
to django-...@googlegroups.com
#34880: Required a post_save_action hook to perform additional action in admin.
-------------------------------+----------------------------------------
Reporter: AjmalPonneth | Owner: AjmalPonneth
Type: New feature | Status: closed
Component: contrib.admin | Version: 4.2
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+----------------------------------------

Comment (by Mariusz Felisiak):

Also, `post_save` signal already exists and we don't want to add redundant
`contrib`-specific signals.

--
Ticket URL: <https://code.djangoproject.com/ticket/34880#comment:2>

Reply all
Reply to author
Forward
0 new messages