Opened 2 years ago

Closed 2 years ago

#27809 closed New feature (wontfix)

Add pre_add and post_add signals

Reported by: Oskar Persson Owned by: Oskar Persson
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords: signals, many-to-one
Cc: Triage Stage: Someday/Maybe
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

There currently aren't any signals that are triggered when adding an object to a Many-To-One relation. This prevents a developer from adding additional custom functionality whenever this occurs. Currently the only way around this is using add with bulk=False which uses the save method instead of update, which isn't always what you want to use.

When bulk=True an update query is used which means that #21461 would also solve this issue. The problem with #21461 however is that there you want all the objects added to the relation sent with the signal. In the pre_add and post_add signals these aren't needed, here we only send the object that other objects are added to, the "related" object.

Change History (4)

comment:1 Changed 2 years ago by Oskar Persson

Needs documentation: set
Needs tests: set

comment:2 Changed 2 years ago by Oskar Persson

Owner: changed from nobody to Oskar Persson
Status: newassigned

comment:3 Changed 2 years ago by Tim Graham

Triage Stage: UnreviewedSomeday/Maybe

The django-developers discussion hasn't yielded consensus about adding this (PR).

comment:4 Changed 2 years ago by Tim Graham

Resolution: wontfix
Status: assignedclosed

I haven't seen an argument for fixing this instead of #21461.

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