The [https://docs.djangoproject.com/en/1.7/ref/signals/ signals
documentation] says nothing about transactions.
Looking in deletion.py,
[https://github.com/django/django/blob/fb48eb05816b1ac87d58696cdfe48be18c901f16/django/db/models/deletion.py#L282-L288
pre_delete and post_delete are within a transaction].
In base.py, however,
[https://github.com/django/django/blob/378a0d27d630386c1b0a53d4a2d48be767453198/django/db/models/base.py#L717-L719
pre_save] and
[https://github.com/django/django/blob/378a0d27d630386c1b0a53d4a2d48be767453198/django/db/models/base.py#L730-L732
post_save] are ''not'' within a transaction.
Whether this inconsistency is a bug is beyond my Django knowledge to
determine, but regardless, '''it should be clear in the documentation what
signals are within transactions'''.
--
Ticket URL: <https://code.djangoproject.com/ticket/24228>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_docs: => 0
* version: 1.7 => master
* needs_tests: => 0
* stage: Unreviewed => Accepted
Comment:
I think the `pre_save` should really be inside the same transaction as the
`save` part. I'm a bit less convinced about the `post_save` (that is
should a `post_save` error be able to "cancel" a `save`?), but it might be
the case also.
--
Ticket URL: <https://code.djangoproject.com/ticket/24228#comment:1>