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

Hard delete in Django admin #76

Open
Vayel opened this issue Mar 23, 2021 · 2 comments
Open

Hard delete in Django admin #76

Vayel opened this issue Mar 23, 2021 · 2 comments

Comments

@Vayel
Copy link

Vayel commented Mar 23, 2021

Hi!

It would be nice to be able to hard delete objects from the Django admin. This can be done this way:

from django.contrib.admin import actions

class SoftDeleteObjectAdmin(admin.ModelAdmin):
    actions = ['delete_selected', 'soft_undelete', 'hard_delete']

    def delete_queryset(self, request, queryset):
        # https://github.com/django/django/blob/main/django/contrib/admin/actions.py#L45
        super(queryset.__class__, queryset).delete()

    def hard_delete(self, request, queryset):
        return actions.delete_selected(self, request, queryset)
    hard_delete.short_description = 'Hard delete selected objects'
@shekarneo
Copy link

how can be enable hard_delete button in admin

PratikBodawala pushed a commit to PratikBodawala/django-softdelete that referenced this issue Apr 3, 2022
@PratikBodawala
Copy link
Contributor

this is merged into the master branch, we can close this issue. @Vayel

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