django-watch
Lightweight Django middleware for real-time request logging during development.
Prints the resolved view's source file, function name, line number, HTTP status, SQL stats, memory usage, and wall-clock timing straight to your terminal — no extra configuration required.
Each request/response pair is colour-coded with a matching emoji so nested or interleaved requests are easy to follow at a glance.
Installation
pip install django-watch
Quick start
Add the middleware at the end of your settings.py:
if DEBUG:
INSTALLED_APPS += ("django_watch",)
MIDDLEWARE += ("django_watch.middleware.WatchMiddleware",)
Open your development console and you will see output like this:
🟢 GET main/views.py • profile • Line 191
🟢 kwargs: {'username': 'sobolev'}
🟢 headers: Content-Type: text/html | Accept: */*
🟢 GET main/views.py • profile [ OK ] • STATUS 200 • 0.12s • SQL 5q/0.03s • 1 dupes • 2.4KB text/html • mem Δ+128KB
🟢 response headers: Content-Type: text/html | Cache-Control: max-age=0
🔵 POST main/views.py • login • Line 42
🔵 request.POST: <QueryDict: {'email': ['user@example.com']}>
🔵 headers: Content-Type: application/x-www-form-urlencoded
🔵 POST main/views.py • login [ OK ] • STATUS 302 • 0.05s • SQL 2q/0.01s • 0B text/html
🔵 response headers: Location: /dashboard/
🟣 GET main/views.py • dashboard • Line 80
🟣 GET main/views.py • dashboard [ OK ] • STATUS 200 • 0.31s • SQL 8q/0.09s • 3 dupes • 12.1KB text/html
🟣 response headers: Content-Type: text/html; charset=utf-8
Colours and emoji rotate automatically: 🟢 🔵 🟣 🩵 ⚪ 💚 💙 💜 — red is reserved for exceptions.
What it logs
| Phase | Information |
|---|---|
| Before view | HTTP method, source file, view function, line number |
| Request data | args, kwargs, GET, POST, raw body (truncated) |
| Request headers | Authorization (masked), Content-Type, Accept, X-Requested-With |
| After view | Status code, total time, response size and Content-Type |
| Response headers | Content-Type, Location, Cache-Control, Set-Cookie, X-Frame-Options |
| SQL | Query count, total query time, duplicate query count (N+1 detection) |
| Memory | RSS delta before/after view |
| On exception | Full Python traceback with ❌ marker |
Running tests
uv sync
uv run pytest
The test suite uses an in-memory SQLite database and covers the full middleware chain: view resolution logging, SQL query counting with duplicate detection, request header output, response metadata, emoji rotation, and exception tracebacks.
Requirements
- Python 3.8+
- Django 3.2+
License
MIT
Metadata
Release files for django-watch 0.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_watch-0.6.1.tar.gz | 8.7 kB | Without provenance | Details for django_watch-0.6.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_watch-0.6.1-py3-none-any.whl | Python 3 | none | any | Details for django_watch-0.6.1-py3-none-any.whl |
Total release size: 16.3 kB
Release files / django_watch-0.6.1.tar.gz
| Download URL | django_watch-0.6.1.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
61578057220555da3fd5758cc1252a7f72619020a6e2ff3f918d7b5b1f0ba9bf
|
|
BLAKE2b-256 checksum How to use checksums |
5374fb4b93e28a213e95294c9a0ec66c80a0fa19dddf6827260977a6a7e8dca5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / django_watch-0.6.1-py3-none-any.whl
| Download URL | django_watch-0.6.1-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3d54386bd76f9ce18263f48396fd56ee4289d619e249c3fc71a0fa61a21b7777
|
|
BLAKE2b-256 checksum How to use checksums |
5e8ee388f86d4dd24330b650e40621611f1ec791795ee5e5062daeaa1a036346
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for django-watch 0.6.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.