728x90
Code
def delete_queryset(self, request, queryset):
for q in queryset:
q.removed_at = timezone.now()
q.save()
Django admin default delete action override delete_queryset
So I want to customize soft delete put that code in admin code
and in model class put in this code you can soft delete to use delete() action
def delete(self):
self.removed_at = timezone.now()
self.save()
def hard_delete(self):
super().delete()
'Django > admin' 카테고리의 다른 글
django 공통 filter 만드는 방법 (0) | 2023.12.09 |
---|---|
Django admin 필드 image로 나타내기 (0) | 2023.12.09 |