django-chronos
Django middleware that shows you how fast your pages load, right in your browser. Displays request timing and query counts for your views and middleware.
TODO: Image
Installation
Install Django Chronos using pip:
pip install django-chronos
Quick Start
- Add to INSTALLED_APPS in your Django settings:
INSTALLED_APPS = [
# ... your other apps
'chronos',
]
- Add middleware to your Django settings (order matters):
MIDDLEWARE = [
'chronos.middleware.ChronosStartMiddleware', # Must be first
# ... your other middleware
'chronos.middleware.ChronosEndMiddleware', # Must be last
]
- Run your Django application and visit any page. You'll see a stats overlayed in the bottom-left corner.
Configuration
CHRONOS_SHOW_IN_PRODUCTION (default: False)
Controls whether stats are shown in production mode (DEBUG=False). Stats are only shown to superusers in production. Stats always show in DEBUG mode.
CHRONOS_SHOW_IN_PRODUCTION = True
CHRONOS_SWAP_METHOD (default: 'prepend')
Controls how the stats are inserted into the response:
'prepend': Insert stats before the target'append': Insert stats after the target'replace': Replace the target with stats
CHRONOS_SWAP_METHOD = 'append'
CHRONOS_SWAP_TARGET (default: '</body>')
The string in the response where stats will be swapped in. Stats will not be displayed if this string does not exist in the response.
CHRONOS_SWAP_TARGET = '</body>'
Customizing the Stats Display
You can override the default stats display by creating your own chronos/chronos.html template in your Django project.
The template receives the following context variables:
middleware_cpu_time,middleware_sql_time,middleware_sql_count,middleware_total_timeview_cpu_time,view_sql_time,view_sql_count,view_total_timetotal_cpu_time,total_sql_time,total_sql_count,total_time
Note: In production mode, the *_sql_time and *_sql_count variable values will be zero (why?). You can wrap these variables in {% if debug %} blocks to stop them from displaying in production.
License
This project is open source and available under the MIT License.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Appreciation
Adam Hill for the inspiration via his Mastodon thread.
Metadata
Release files for django-chronos 250807
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 | |
|---|---|---|---|---|
| django_chronos-250807.tar.gz | 4.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_chronos-250807-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.7 kB
Release files / django_chronos-250807.tar.gz
| Download URL | django_chronos-250807.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb7c987d561d76e35e75581c2946371020973a941c1a2d9c23f4168cc4ed1371
|
|
BLAKE2b-256 checksum How to use checksums |
2963b4662d2f98e337e6a93f89b7aa35edb46f3def52d2af248acbaa283640c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.3
|
Release files / django_chronos-250807-py3-none-any.whl
| Download URL | django_chronos-250807-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8be5560b95804c46117e7b992c1eede7ba76e4e01bd1cd4b15ef7e8fe63cca76
|
|
BLAKE2b-256 checksum How to use checksums |
92fdb31a6882345ac3b0a1e1a7effdd581f9b97f937fee6c0d8ea5b4cbb0a3b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.3
|
Security for django-chronos 250807
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.