Skip to content

Restoring soft-deleted child objects of an object being restored #68

@helgihg

Description

@helgihg

Thanks for a cool library.

I've been messing around with the code to try and make it restore child objects of an object being restored. The childrens' parent class is of course PermanentModel as well, but their respective foreign key is cleared upon soft deletion at the time when their parent object is soft-deleted.

Tracing my way through the code, it appeared that this separation of foreign keys was taking place at deletion.py:98 (setattr(obj, field.attname, value)). I tried setting up an optional parameter to the .delete() function, preserve_foreign_keys=False (by default), but even when making absolutely sure that the aforementioned line is not running, the behavior is not changed. The foreign key of the soft-deleted child objects to the parent object still gets removed somewhere else.

At this point I figured I might as well just ask here if this is a feature to be expected. Or if this possibly just a really bad idea. I think it would be lovely!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions