All Projects → makinacorpus → Django Safedelete

makinacorpus / Django Safedelete

Licence: other
Mask your objects instead of deleting them from your database.

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Django Safedelete

Awesome Django Admin
Curated List of Awesome Django Admin Panel Articles, Libraries/Packages, Books, Themes, Videos, Resources.
Stars: ✭ 356 (-5.07%)
Mutual labels:  django
Django Postgres Extra
Bringing all of PostgreSQL's awesomeness to Django.
Stars: ✭ 365 (-2.67%)
Mutual labels:  django
Django Admin Rangefilter
django-admin-rangefilter app, add the filter by a custom date range on the admin UI
Stars: ✭ 370 (-1.33%)
Mutual labels:  django
Try Django 1.11
Learn the fundamentals behind one of the most popular web frameworks in the world: Django. We will teach you step-by-step how to implement concepts like Views, Template Rendering, Forms, Saving Data, URL routing, Deployment aka Going Live, and so much more. Django is a web-framework written in Python and runs the backend for many of the internet's most popular websites such as Instagram and Pinterest. Get started today!
Stars: ✭ 359 (-4.27%)
Mutual labels:  django
Django Tutorial
Django 基本教學 - 從無到有 Django-Beginners-Guide 📝
Stars: ✭ 365 (-2.67%)
Mutual labels:  django
Healthchecks
A cron monitoring tool written in Python & Django
Stars: ✭ 4,297 (+1045.87%)
Mutual labels:  django
Collectfast
A faster collectstatic command.
Stars: ✭ 352 (-6.13%)
Mutual labels:  django
Nefarious
Web application for automatically downloading TV & Movies
Stars: ✭ 373 (-0.53%)
Mutual labels:  django
Firefox Profilemaker
Tool to create firefox profiles with good defaults.
Stars: ✭ 361 (-3.73%)
Mutual labels:  django
Django Getpaid
Django payments processor.
Stars: ✭ 371 (-1.07%)
Mutual labels:  django
Django Bakery
A set of helpers for baking your Django site out as flat files
Stars: ✭ 360 (-4%)
Mutual labels:  django
Pretalx
Conference planning tool: CfP, scheduling, speaker management
Stars: ✭ 363 (-3.2%)
Mutual labels:  django
Django Api Domains
A pragmatic styleguide for Django API Projects
Stars: ✭ 365 (-2.67%)
Mutual labels:  django
Django Watchman
django-watchman exposes a status endpoint for your backing services like databases, caches, etc.
Stars: ✭ 357 (-4.8%)
Mutual labels:  django
Django Cruds Adminlte
django-cruds is simple drop-in django app that creates CRUD for faster prototyping
Stars: ✭ 373 (-0.53%)
Mutual labels:  django
Graphene Django Extras
Extras functionalities for Graphene-Django
Stars: ✭ 356 (-5.07%)
Mutual labels:  django
Django Blog
django搭建博客
Stars: ✭ 365 (-2.67%)
Mutual labels:  django
Django Private Chat
Django one-to-one Websocket-based Asyncio-handled chat, developed by Bearle team
Stars: ✭ 376 (+0.27%)
Mutual labels:  django
Django Object Actions
A Django app for easily adding object tools in the Django admin
Stars: ✭ 374 (-0.27%)
Mutual labels:  django
Django User Sessions
Extend Django sessions with a foreign key back to the user, allowing enumerating all user's sessions.
Stars: ✭ 368 (-1.87%)
Mutual labels:  django

Django safedelete

.. image:: https://github.com/makinacorpus/django-safedelete/workflows/Python%20application/badge.svg :target: https://github.com/makinacorpus/django-safedelete/actions?query=workflow%3A%22Python+application%22

.. image:: https://coveralls.io/repos/makinacorpus/django-safedelete/badge.png :target: https://coveralls.io/r/makinacorpus/django-safedelete

What is it ?

For various reasons, you may want to avoid deleting objects from your database.

This Django application provides an abstract model, that allows you to transparently retrieve or delete your objects, without having them deleted from your database.

You can choose what happens when you delete an object :

  • it can be masked from your database (soft delete, the default behavior)
  • it can be masked from your database and mask any dependent models. (cascading soft delete)
  • it can be normally deleted (hard delete)
  • it can be hard-deleted, but if its deletion would delete other objects, it will only be masked
  • it can be never deleted or masked from your database (no delete, use with caution)

Example

.. code-block:: python

# imports
from safedelete.models import SafeDeleteModel
from safedelete.models import HARD_DELETE_NOCASCADE

# Models

# We create a new model, with the given policy : Objects will be hard-deleted, or soft deleted if other objects would have been deleted too.
class Article(SafeDeleteModel):
    _safedelete_policy = HARD_DELETE_NOCASCADE

    name = models.CharField(max_length=100)

class Order(SafeDeleteModel):
    _safedelete_policy = HARD_DELETE_NOCASCADE

    name = models.CharField(max_length=100)
    articles = models.ManyToManyField(Article)


# Example of use

>>> article1 = Article(name='article1')
>>> article1.save()

>>> article2 = Article(name='article2')
>>> article2.save()

>>> order = Order(name='order')
>>> order.save()
>>> order.articles.add(article1)

# This article will be masked, but not deleted from the database as it is still referenced in an order.
>>> article1.delete()

# This article will be deleted from the database.
>>> article2.delete()

Compatibilities

  • Branch 0.2.x is compatible with django >= 1.2
  • Branch 0.3.x is compatible with django >= 1.4
  • Branch 0.4.x is compatible with django >= 1.8
  • Branch 0.5.x is compatible with django >= 1.11
  • Branch 1.0.x is compatible with django >= 2.2

Current branch (1.0.x) is tested with :

  • Django 2.2 using python 3.5 to 3.9.
  • Django 3.0 using python 3.6 to 3.9.
  • Django 3.1 using python 3.6 to 3.9.

Installation

Installing from pypi (using pip). ::

pip install django-safedelete

Installing from github. ::

pip install -e git://github.com/makinacorpus/django-safedelete.git#egg=django-safedelete

Add safedelete in your INSTALLED_APPS:

.. code-block:: python

INSTALLED_APPS = [
    'safedelete',
    [...]
]

The application doesn't have any special requirement.

Configuration

In the main django settings you can activate the boolean variable SAFE_DELETE_INTERPRET_UNDELETED_OBJECTS_AS_CREATED. If you do this the update_or_create() function from django's standard manager class will return True for the created variable if the object was soft-deleted and is now "revived".

Documentation

The documentation is available here <http://django-safedelete.readthedocs.org>_. Generate your own documentation using:

tox -e docs

Licensing

Please see the LICENSE file.

Contacts

Please see the AUTHORS file.

.. image:: https://drupal.org/files/imagecache/grid-3/Logo_slogan_300dpi.png :target: http://www.makina-corpus.com

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].