Documentation should be clearer about when save and delete are called.
|Reported by:||Richard Bell <rbell01824@…>||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
An hour later I know what caused the behavior and it seems to me to be a Django bug or at least deficiency.
This behavior occurred during an initialization of the application.
First the table xx_xxnode was initialized by deleting all of its records and then reloading the table from an external source. It has a character field primary key.
Then the table xx_xxraid needs to be initialized. xx_xxraid has a foreign key to the table xx_xxnode. However, when xx_xxnode's records were deleted, Django also deleted the linked records in xx_xxraid since the keys were no longer valid. All of which is OK and if I read the documents closely is in fact documented.
However, there is a problem. The model for xx_xxraid overrides the delete method. While the records in xx_xxraid are in fact being deleted as an (appropriate) side effect of the delete of xx_node's records the delete method of xx_xxraid is NOT being invoked. It seems likely that add and delete are overrides associated with the admin interface NOT, sadly, with the DB API.
No joy, but at least I know what is going on.