Use this package if you want a soft delete in your model that remove the entries in your admin but not from the database.
The full documentation is at https://django-soft-delete-model-mixin.readthedocs.io.
Install Soft Delete Model Mixin:
pip install django-soft-delete-model-mixin
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'soft_delete_model_mixin',
...
)
Add it to your Model:
from soft_delete_model_mixin import urls as soft_delete_model_mixin_urls
class Book(SoftDeleteModelMixin, models.Model):
objects = BookManager.from_queryset(BookQuerySet)()
title = models.CharField("Title", max_length=255)
class Meta:
"""Book Meta."""
verbose_name = "Book"
verbose_name_plural = "Books"
def __str__(self):
return self.title
Use it in your Admin:
@admin.register(Book)
class BookAdmin(SoftDeleteModelAdmin):
list_display = ("title",)
fields = ("title",)
- TODO
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
pip install -r requirements_dev.txt invoke -l
Tools used in rendering this package: