Skip to main content

this application is for handling delete operations in the system

Project description

Soft Delete

This package is used for implementing soft delete functionality in models, when used you can delete and restore deleted items unless it was hard deleted from the database.

Installation

pip install dj-soft-delete

Usage

you can use it by extending HasSoftDelete class in your model

    from django_soft_delete.models import HasSoftDelete
    
    
    class Item(HasSoftDelete):
        ...
  • retrieving items without deleted
    Item.objects.all()
  • retrieving items with deleted
    Item.with_trashed_objects.all()
  • **retrieving deleted items only
    Item.with_trashed_objects.deleted()
  • Soft deleting item
    # via objects manager
    Item.objects.filter(...).delete()

    # via model instance
    item = Item.objects.get(...)
    item.delete()
  • herd deleting items
    # via objects manager
    Item.objects.filter(...).hard_delete()

    # via model instance
    item = Item.objects.get(...)
    item.hard_delete()
  • Restore soft deleted items
    # via objects manager
    Item.with_trashed_objects.filter(...).restore()
    
    # via model instance
    item = Item.with_trashed_objects.get(...)
    item.restore()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dj_soft_delete-1.0.1.tar.gz (7.0 kB view hashes)

Uploaded Source

Built Distribution

dj_soft_delete-1.0.1-py3-none-any.whl (9.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page