Models
DeletedObject
pragmatic.models.DeletedObject
Stores an audit record whenever a model instance is deleted through
DeleteObjectMixin. Requires PRAGMATIC_TRACK_DELETED_OBJECTS = True
in your settings.
from pragmatic.models import DeletedObject
Fields:
Field |
Description |
|---|---|
|
FK to |
|
The primary key of the deleted instance |
|
|
|
FK to the user who triggered the deletion; |
|
Timestamp of deletion (auto-set, db-indexed) |
The model uses get_latest_by = 'datetime' and orders by datetime
ascending.
Setup
Enable tracking in settings:
PRAGMATIC_TRACK_DELETED_OBJECTS = True
Run migrations:
python manage.py migrate pragmatic
Use
DeleteObjectMixin(orCheckProtectedDeleteObjectMixin) on your delete views — records are created automatically.