Opened 18 years ago
Closed 18 years ago
#4879 closed (fixed)
post_create signal
| Reported by: | Owned by: | George Vilches | |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | dev | 
| Severity: | Keywords: | sprintsept14 | |
| Cc: | gav@… | Triage Stage: | Accepted | 
| Has patch: | yes | Needs documentation: | no | 
| Needs tests: | no | Patch needs improvement: | no | 
| Easy pickings: | no | UI/UX: | no | 
Description
Patch adds post_create signal to model's save() method. This signal is useful to interact with newly created objects.
Attachments (7)
Change History (14)
by , 18 years ago
| Attachment: | post_create_patch.diff added | 
|---|
comment:1 by , 18 years ago
| Triage Stage: | Unreviewed → Accepted | 
|---|
by , 18 years ago
| Attachment: | post_save_with_created_kw.patch added | 
|---|
Adds a "created" flag to the post_save signal.
comment:3 by , 18 years ago
| Cc: | added | 
|---|
+1 to mtredinnick's idea for just adding a flag to the post_save signal.  The patch I attached does exactly this, and uses a variable that already existed in the save() method that held this information anyway (it was missing one place it needed to be set, so the patch handles that as well), so the additional overhead should be nothing.
by , 18 years ago
| Attachment: | post_save_with_created_kw_r5991.patch added | 
|---|
Updated patch for post_save created signal against r5991.
by , 18 years ago
| Attachment: | django_unit_test_model_signals.diff added | 
|---|
Unit test for all model signals, including testing the post_save created keyword
comment:4 by , 18 years ago
The django_unit_test_model_signals.diff includes a unit tests for the Django test suite covering the following signals:
pre_save post_save pre_delete post_delete
It verifies that these signals fire in the proper order, that they have the expected instance of the model, and that the created flag on post_save is correctly set.
As far as I could tell, tests for these signals do not exist anywhere.
comment:5 by , 18 years ago
| Owner: | changed from to | 
|---|
I'll take responsibility for cleaning up this ticket for the sprint.
by , 18 years ago
| Attachment: | post_save_with_created_kw_r6184.patch added | 
|---|
Post save patch + unit tests against r6184
comment:6 by , 18 years ago
| Keywords: | sprintsept14 added | 
|---|
comment:7 by , 18 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | new → closed | 
There was a general consensus in a recent django-dev thread about this. No core developer spoke against it. The only question is whether to make it a new signal, or a flag attached to the post_save signal (signal emissions are not free). I'll have to rummage through the archives. Marking this as "accepted" though, since it's reasonable.