As the title says, I use the django-simple-history 3.1.1 module to automatically generate a history of all my models.
The module creates duplicates of each of my Models to store the generated Historical Objects, with a copy of the modified object, the date, the user …
So by browsing through these historical tables I can trace every modification that took place on an object of this table.
The module works fine when I create, modify or delete an object, but the problem arises when I have set inheritances between my models with cascading deletion of child objects if the parent is deleted, as Django allows.
When I make a deletion of an object that by cascade delete one or more others and when I just want to query the
Historical Objects, I do have the one in the parent table, but for objects in the children table I have this error :
MyApp.models.parentTable_object.DoesNotExist: parentTable_object matching query does not exist.
If I understand the problem, django-simple-history tried to create a
Historical object for my deleted object but failed because it needed the parent object it inherited and that no longer exists at this point.
To be clear, here is a presentation of what I think is happening :
- PERSON - id lastname => Deleting Objet PERSON => django-simple-history generates an object in HistoricalPerson firstname
- PERSON - - HOLIDAYS- id person_object (CASCADE) lastname location => Deleting Objet PERSON => Auto deletion of Objet HOLIDAYS => django-simple-history generates an object in HistoricalPerson firstname date django-simple-history generates an object in HistoricalHolidays /!\ ERROR UNREADABLE, person_object unknown /!\
The django-simple-history documentation does not mention cascading deletion and I haven’t found anything on the forums about it.
I can’t do without cascade deletion and django-simple-history meets all my needs except this one.
If someone has already used this module, could you explain me how to handle this case?
Otherwise, I’m open to advices.
Thank you !