Skip to main content

this library adds 'created_at', 'updated_at' and 'delete_at' fields like a rail apps in django, also added soft delete method

Project description

this library adds ‘created_at’, ‘updated_at’ and ‘delete_at’ fields like a rail apps in django, also added soft delete method.


pip install django-paranoid

How to start

1.- Add to django-paranoid in the django apps:


2.- Extends ParanoidModel in the model to use:

from django_paranoid.models import ParanoidModel

class MyModel(ParanoidModel):
    field = models.CharField(max_length=20)

3.- Add to django-admin:

from django_paranoid.admin import ParanoidAdmin

class MyModelAdmin(ParanoidAdmin):
  ..., MyModelAdmin)

Soft Delete

m = MyModel.objects.last()

This only applies soft delete, so the record will remain in the database, but it will not be visible for normal queries:

m = MyModel.objects.last()

Now the record has a deleted_at field and if do you want show the delete record you could using ‘objects_with_deleted’:

m = MyModel.objects_with_deleted.last()
<MyModel: name>
datetime.datetime(2019, 8, 10, 6, 16, 44, 633727, tzinfo=<UTC>)

Hard Delete

If do you want to delete record from DB, you only should using True param:

m = MyModel.objects.last()

Project details

Download files

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

Files for django-paranoid, version 0.8
Filename, size File type Python version Upload date Hashes
Filename, size django_paranoid-0.8-py3-none-any.whl (17.3 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page