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

content_type

FK to ContentType (the model class that was deleted)

object_id

The primary key of the deleted instance

object_str

str(instance) captured before deletion (max 300 chars)

user

FK to the user who triggered the deletion; NULL for unauthenticated

datetime

Timestamp of deletion (auto-set, db-indexed)

The model uses get_latest_by = 'datetime' and orders by datetime ascending.

Setup

  1. Enable tracking in settings:

    PRAGMATIC_TRACK_DELETED_OBJECTS = True
    
  2. Run migrations:

    python manage.py migrate pragmatic
    
  3. Use DeleteObjectMixin (or CheckProtectedDeleteObjectMixin) on your delete views — records are created automatically.