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

Capability to rename 'deleted' column

Open daviddjia opened this issue 3 years ago • 2 comments

I'm trying to apply django-safedelete to my django repo, but all my tables already have a deleted_at, and I'd to avoid renaming all of these columns, since I use a naming convention where all timestamp columns are appended with _at. Is there any way we can refactor this package to allow me to choose what column name I'd like to use?

I'm currently forking the repo to make a one line change (in models.py), but I'd prefer not to if possible: deleted = models.DateTimeField(name='deleted_at', editable=False, null=True)

daviddjia avatar Aug 12 '21 19:08 daviddjia

I guess the easiest way for you to do that would be to have your own SafeDeleteModel, and using that one:

class CustomSafeDeleteModel(SafeDeleteModel):
    deleted = models.DateTimeField(name='deleted_at', editable=False, null=True)

    class Meta:
        abstract = True

Gagaro avatar Aug 24 '21 07:08 Gagaro

I think you can configure that with the setting: SAFE_DELETE_FIELD_NAME

Check this! https://github.com/makinacorpus/django-safedelete/blob/master/safedelete/config.py

gonzaloamadio avatar Sep 09 '21 18:09 gonzaloamadio