Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capability to rename 'deleted' column #162

Open
daviddjia opened this issue Aug 12, 2021 · 2 comments
Open

Capability to rename 'deleted' column #162

daviddjia opened this issue Aug 12, 2021 · 2 comments

Comments

@daviddjia
Copy link

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)

@Gagaro
Copy link
Member

Gagaro commented Aug 24, 2021

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

@gonzaloamadio
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants