Django Stacktrace
Install from PyPI:
pip install django-stacktrace
A reusable Django app that captures exceptions with request context and stores them in the database, similar to a lightweight Sentry. It is best suited for early-stage apps that do not yet need to invest in a full error tracking tool; for production-grade monitoring, Sentry is recommended.
Quick start
- Add the app:
django_stacktracetoINSTALLED_APPS
- Add middleware (signal fallback is disabled automatically when middleware is enabled):
django_stacktrace.middleware.StacktraceMiddlewareinMIDDLEWARE
- Apply migrations:
python manage.py migrate
- Trigger a crash and inspect
Crash eventsin the Django admin.
Manual capture
You can capture exceptions directly without middleware:
from django_stacktrace.event_store import store_crash_event
try:
1 / 0
except Exception as exc:
store_crash_event(exc=exc)
Settings
All settings live under a single STACKTRACE dictionary. Each key is optional.
STACKTRACE = {
"ENABLED": True,
"SAMPLE_RATE": 1.0,
"RATE_LIMIT": 0,
"CAPTURE_HEADERS": True,
"CAPTURE_BODY": False,
"MAX_PAYLOAD_BYTES": 64 * 1024,
"REDACT_FIELDS": ["password", "token"],
"REDACT_HEADERS": ["authorization", "cookie"],
"USER_FIELD": "username",
}
Available keys:
ENABLED(defaultTrue)SAMPLE_RATE(default1.0, 0-1 sampling probability)RATE_LIMIT(default0, per-minute cap;0disables)CAPTURE_HEADERS(defaultTrue)CAPTURE_BODY(defaultFalse)MAX_PAYLOAD_BYTES(default65536)REDACT_FIELDS(request keys to mask)REDACT_HEADERS(header keys to mask)USER_FIELD(user attribute for display name)
Settings reference
ENABLED
- Type:
bool - Purpose: Enable or disable crash capturing entirely.
- Example:
"ENABLED": False
SAMPLE_RATE
- Type:
floatbetween0.0and1.0 - Purpose: Probabilistic sampling for high-volume apps.
- Example:
"SAMPLE_RATE": 0.1
RATE_LIMIT
- Type:
int - Purpose: Per-minute cap;
0disables rate limiting. - Example:
"RATE_LIMIT": 120
CAPTURE_HEADERS
- Type:
bool - Purpose: Include request headers in the captured event.
- Example:
"CAPTURE_HEADERS": True
CAPTURE_BODY
- Type:
bool - Purpose: Include request body in the captured event.
- Example:
"CAPTURE_BODY": False
MAX_PAYLOAD_BYTES
- Type:
int - Purpose: Max bytes kept from request body.
- Example:
"MAX_PAYLOAD_BYTES": 65536
REDACT_FIELDS
- Type:
list[str]orset[str] - Purpose: Request data keys to mask before storage.
- Example:
"REDACT_FIELDS": ["password", "token"]
REDACT_HEADERS
- Type:
list[str]orset[str] - Purpose: Header keys to mask before storage.
- Example:
"REDACT_HEADERS": ["authorization", "cookie"]
USER_FIELD
- Type:
str - Purpose: User attribute used for display name in the event.
- Example:
"USER_FIELD": "username"
Data model
Events are stored in django_stacktrace.CrashEvent with indexed fields like level,
logger, error type, request path, user identifier, and traceback hash, plus a
JSON payload for full context.
Backlog
- Async storage path (Celery/queue support)
- Logging integration for
loggingexceptions - Rate-limit options (per-user/IP limits, key prefix)
- Body size controls (per-content-type limits, truncation)
- Filtering hooks (ignore exceptions or URLs)
- Admin UI improvements (grouping, search, trends)
- Export and retention tools (cleanup, CSV export)
Release files for django-stacktrace 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_stacktrace-0.2.3.tar.gz | 18.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_stacktrace-0.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 48.0 kB
Release files / django_stacktrace-0.2.3.tar.gz
| Download URL | django_stacktrace-0.2.3.tar.gz |
|---|---|
| Size | 18.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9fe4060853f66b752b8752c5a9dcf7da0ae90be9302cca7ef15ccab98254e316
|
|
BLAKE2b-256 checksum How to use checksums |
8c4e04bd9ac0acdb54970cf124432461f21cb7b6456c87e30f558ac2f82dc553
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 30, 2026.
Transparency logRelease files / django_stacktrace-0.2.3-py3-none-any.whl
| Download URL | django_stacktrace-0.2.3-py3-none-any.whl |
|---|---|
| Size | 29.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
25a4c57f87b27f9428a64f83facab56ab8c4f9c0883ee62300507f41218a13bc
|
|
BLAKE2b-256 checksum How to use checksums |
009c4575653e5a3781ef756392eb78b080aa5a93d07e949212843eb43b535d6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 30, 2026.
Transparency log