django-softdelete icon indicating copy to clipboard operation
django-softdelete copied to clipboard

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

Open ralokt opened this issue 4 years ago • 1 comments

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 avatar Jan 19 '21 12:01 ralokt

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

ralokt avatar Jan 19 '21 12:01 ralokt