scoursen / django-softdelete

Soft delete for Django ORM, with support for undelete.
Other
376 stars 102 forks source link

No good way to undelete objects that don't know that they are deleted yet #74

Open ralokt opened 3 years ago

ralokt commented 3 years ago

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 ).

ralokt commented 3 years ago

(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. )