You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a ModelViewSet with a custom destroy() definition decorated with @transaction.atomic.
When the model object is deleted, the message passed into the model_observer handler does not contain the ID.
I have checked that the ID is present in the instance when ModelObserver.post_delete_receiver() is called.
However, the ID has changed to None when ModelObserver.post_change_receiver() is called.
The ID does not change to None if I remove the @transaction.atomic decorator from destroy() in the ModelViewSet.
Is this behavior expected?
If so, are there any workarounds to retain the ID when model objects are deleted via atomic transactions?
I would like to avoid defining post_delete signal handlers for all my models to send the delete notifications via the AsyncAPIConsumer containing the model_observer definition.
The text was updated successfully, but these errors were encountered:
This is interesting, are other fields still populated (is it just the ID that is lost?)
Yes.
My guess is that the delete transaction has completed and the ID is set to None in the referenced instance after ModelObserver.post_change_receiver() is called.
I have a ModelViewSet with a custom
destroy()
definition decorated with@transaction.atomic
.When the model object is deleted, the
message
passed into the model_observer handler does not contain the ID.I have checked that the ID is present in the instance when
ModelObserver.post_delete_receiver()
is called.However, the ID has changed to None when
ModelObserver.post_change_receiver()
is called.The ID does not change to None if I remove the
@transaction.atomic
decorator fromdestroy()
in the ModelViewSet.Is this behavior expected?
If so, are there any workarounds to retain the ID when model objects are deleted via atomic transactions?
I would like to avoid defining post_delete signal handlers for all my models to send the delete notifications via the AsyncAPIConsumer containing the model_observer definition.
The text was updated successfully, but these errors were encountered: