django-softdelete
django-softdelete copied to clipboard
No good way to undelete objects that don't know that they are deleted yet
Let's say I have two model objects foo
and bar
, and let's say that soft deleting foo
has the side effect of also soft deleting bar
.
For unit testing, I'd like to be able to do something like
foo.delete()
(...)
foo.undelete()
bar.undelete()
This will fail with an AssertionError
because bar
is desynchronized from the db. However, we also can't use bar.refresh_from_db()
because the default manager doesn't find it anymore (see also: #73 ).
(A side note: as a workaround, the following works for me:
foo.delete()
bar.deleted = True
(...)
foo.undelete()
bar.undelete()
But also, that is very hacky. )