django-model-utils
django-model-utils copied to clipboard
Should Softdelete use deleted_at
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?
Hi!
I think the TimeStampedModel
does exactly that.
https://github.com/jazzband/django-model-utils/blob/eb00f65c81fb26dc73826d0e33d564d1b079f9a0/model_utils/models.py#L22
not quite. If timestamped model also added a deleted_at
that was a timestamp then yes.
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.