django-model-utils icon indicating copy to clipboard operation
django-model-utils copied to clipboard

Should Softdelete use deleted_at

Open morenoh149 opened this issue 4 years ago • 3 comments

Problem

I was reviewing https://django-model-utils.readthedocs.io/en/latest/models.html#softdeletablemodel and see that it uses a boolean. Could we add another model that uses created_at that is a timestamp? thoughts?

morenoh149 avatar May 04 '20 17:05 morenoh149

Hi!

I think the TimeStampedModel does exactly that. https://github.com/jazzband/django-model-utils/blob/eb00f65c81fb26dc73826d0e33d564d1b079f9a0/model_utils/models.py#L22

marcorichetta avatar Aug 14 '20 01:08 marcorichetta

not quite. If timestamped model also added a deleted_at that was a timestamp then yes.

morenoh149 avatar Aug 14 '20 14:08 morenoh149

Maybe you can combine TimeStampedModel and SoftDeletableModel.

For example, if an object is deleted, the modified field should have the timestamp of the deletion. Obviously you can still modify it, and that timestamp would not reference anymore the time of deletion.

That being said, I see a valid reason on the field you want to add.

marcorichetta avatar Aug 15 '20 00:08 marcorichetta