Add your description here
Project description
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)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_stacktrace-0.2.1.tar.gz.
File metadata
- Download URL: django_stacktrace-0.2.1.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
007cc8fa3cfed02381c87a3651852ad9cb07fe0182117f5ce69c8b01c212527e
|
|
| MD5 |
f2b697c06d24bec625d63d82d0c31459
|
|
| BLAKE2b-256 |
0fa6811eba8144750b27b047bba0e7cb1dc7fbd7f44e34c5c56b403cab0c9e23
|
Provenance
The following attestation bundles were made for django_stacktrace-0.2.1.tar.gz:
Publisher:
release.yml on marselbeqiri/django-stacktrace
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_stacktrace-0.2.1.tar.gz -
Subject digest:
007cc8fa3cfed02381c87a3651852ad9cb07fe0182117f5ce69c8b01c212527e - Sigstore transparency entry: 869017421
- Sigstore integration time:
-
Permalink:
marselbeqiri/django-stacktrace@7c8e07cfeb4e6d91196800ff54aace8d9a47455e -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/marselbeqiri
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7c8e07cfeb4e6d91196800ff54aace8d9a47455e -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_stacktrace-0.2.1-py3-none-any.whl.
File metadata
- Download URL: django_stacktrace-0.2.1-py3-none-any.whl
- Upload date:
- Size: 28.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6ce601c84449c36f5f59aa13766b35a6401e32b55ce4dbc627c158d759aa079
|
|
| MD5 |
9de03c2ecc7cb587b559618bd4a5db48
|
|
| BLAKE2b-256 |
1006e658cdf06179d1f15a120354016f512b6da904895b08e9e635244e7c2e0f
|
Provenance
The following attestation bundles were made for django_stacktrace-0.2.1-py3-none-any.whl:
Publisher:
release.yml on marselbeqiri/django-stacktrace
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_stacktrace-0.2.1-py3-none-any.whl -
Subject digest:
c6ce601c84449c36f5f59aa13766b35a6401e32b55ce4dbc627c158d759aa079 - Sigstore transparency entry: 869017424
- Sigstore integration time:
-
Permalink:
marselbeqiri/django-stacktrace@7c8e07cfeb4e6d91196800ff54aace8d9a47455e -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/marselbeqiri
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7c8e07cfeb4e6d91196800ff54aace8d9a47455e -
Trigger Event:
push
-
Statement type: