scoursen / django-softdelete

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

Undelete does not clear the deleted at field #62

Open natehawkboss opened 4 years ago

natehawkboss commented 4 years ago

The issue I am noticing is that when you undelete a record, it makes the change in the database but does not seem to change the model instance.

So I have a deleted record, I undelete, make changes, and save

model.undelete()
model.field1 = 1
model.field2 = 2
model.save()
model.deleted
>>> True

then the deleted at field is still in the instance and it is re-added; it has a deleted_at so it shows as deleted, yet it doesn't have the changeset to undelete it. As of now, I have to explicitly call refresh_from_db to update

model.undelete()
model.deleted
>>> True
model.refresh_from_db()
model.deleted
>>> False
model.field1 = 1
model.field2 = 2
model.save()
model.deleted
>>> False

or just do all of my changes and then call undelete

model.field1 = 1
model.field2 = 2
model.save()
model.undelete()

it seems that undelete should not just update the table but the model instance as well.