Skip to main content

build Open Source Love svg3 license release download GitHub stars

django-paranoid

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

install

pip install django-paranoid

How to start

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

INSTALLED_APPS = [
    'django.contrib.admin',
  'django.contrib.auth',
        ...
  'django_paranoid'
  ...
]

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):
    pass
  ...
admin.site.register(MyModel, MyModelAdmin)

Soft Delete

m = MyModel.objects.last()
m.delete()

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()
>>> m
>>>

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()
>>> m
<MyModel: name>
>>> m.deleted_at
datetime.datetime(2019, 8, 10, 6, 16, 44, 633727, tzinfo=<UTC>)

Restore Soft Delete

On object which was soft deleted, follow steps above to restore object

m.restore()

Hard Delete

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

m = MyModel.objects.last()
m.delete(True)

Release files for django-paranoid 1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-paranoid 1.0
File Size Uploaded
django-paranoid-1.0.tar.gz 2.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-paranoid 1.0
File Interpreter ABI Platform
django_paranoid-1.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.8 kB

Release files / django-paranoid-1.0.tar.gz

Download URL django-paranoid-1.0.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
17771ff2f20e1a151d10039080de15fcae9338abb9b90fca44b59cd00a0d1118
BLAKE2b-256 checksum
How to use checksums
31dd0a0ab57be112bc253b1ef9f971620532d77799e2cce9f3e205034bfb792a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

Release files / django_paranoid-1.0-py3-none-any.whl

Download URL django_paranoid-1.0-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6bc8650bf0fab8f09c52bdc499264a4e1aaa6f60a495f82a8606276bdf135a84
BLAKE2b-256 checksum
How to use checksums
b9a3c80c4d33297958aed6a90ef314c8f4dda2bff5271b9273c8877c85093edd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

Release history Release notifications | RSS feed

This release

1.0 This release

2 release files

0.9

2 release files

0.8

1 release file

0.7

1 release file

0.6

1 release file

0.5

1 release file

0.4

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page