GithubHelp home page GithubHelp logo

django-logical-delete's Introduction

Django Logical Delete

This is a small and simple app that I threw together to get some reuse out of something I do in nearly every project and every model I create. It's too easy for good data to get deleted and it be unrecoverable. It's also too easy to fix this by overriding the model's delete() method and just flagging records as deleted and then leveraging Django's Managers to override default behavior so that logically deleted items are not returned in querysets.

There are two exceptions however, that I have found useful to this rule.

  1. In the admin I like to see everything with an indicator of whether or not it has been deleted, with the ability to filter down to just active records, (or deleted for that matter).
  2. I still think it is a valid request when an item is fetched for by it's primary key value, that the object should return, even if it is marked as deleted.

Installing django-logicaldelete

pip install django-logicaldelete

Using django-logicaldelete

Using the app is pretty simple:

  1. add logicaldelete to your INSTALLED_APPS
  2. Inherit from logicaldelete.models.Model for all models that you 11wish to share in this functionality.
  3. Create and/or Register admins for each of these models using logicaldelete.admin.ModelAdmin

Additional

Logical deletes are handled by date stamping a date_removed column. In addition, a date_created and date_modified columns will be populated as a convenience.

Backwards Incompatible Changes

1.1

  • Changed everything to all_with_deleted on LogicalDeleteManager
  • LogicalDeleteManager moved from logicaldelete.models to logicaldelete.managers
  • Removed deleted and everything querysets from logicaldelete.models.Model

django-logical-delete's People

Contributors

angvp avatar binarymatt avatar paltman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

acangiani

django-logical-delete's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.