Git Product home page Git Product logo

django-softdel's Introduction

django-softdel

English | 简体中文

Implemented a model for soft deletion (logical deletion) Soft deletion:

The deleted data in the application layer is not deleted in the database but is shielded from the application layer

Feature

Inheriting the SoftDeleteModel model will result in the following features:

  • Automatically add a field delete_time [field name configurable]
  • Data will be marked as deleted and will not be removed from the database on delete
  • Automatically add deleted filter rule to the current QuerySet(include relation QuerySet) [optional]
  • Tables with foreign key relationships will also undergo soft deletion during cascading deletion [optional]
  • Fields with unique constraints will be adjusted to joint unique constraints with 'delete_time' [optional]

Example

  1. Install package:

    pip install django-softdel
    
  2. install softdel app

    INSTALLED_APPS =[
        "softdel",
        ...
    ]
  3. Inherit model

    from django.db import models
    from softdel.models import SoftDeleteModel
    
    class YourModel(SoftDeleteModel):
        pass
  4. Migration:

    python manage.py makemigrations
    python manage.py migrate
    

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.