django-cprofile-middleware
Easily add cProfile profiling to django views.
What it is and what it does
django-cprofile-middleware is a Django middleware that wraps request handling with Python's cProfile profiler. When you add `?prof` to any URL while logged in as a staff user (by default), the middleware captures function-call timing data and displays it inline, letting you see which functions consumed the most CPU time during that request. It supports sorting results by different metrics and downloading the profile data for visualization in external tools.
The middleware activates only when Django's DEBUG setting is True and (by default) when the requesting user has staff privileges. It's a development-only tool for identifying performance bottlenecks without manual instrumentation.
Use it for:
- Identify slow database queries or expensive function calls in a Django view during local development
- Compare performance across different code paths by profiling the same endpoint with different parameters
- Export profile data for detailed visualization of call hierarchies in external profiling viewers
- Debug performance regressions by profiling a view before and after code changes
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Middleware that profiles Django view execution using cProfile and displays results inline when a query parameter is added to any request.
No. The package is abandoned (last release 2020-02-20, last commit 2021-08-18) with no active maintenance or security updates. Modern Django and Python versions may have broken compatibility. For profiling Django views, prefer actively maintained alternatives.
Install
django-cprofile-middleware on PyPI
pip
pip install django-cprofile-middlewareuv
uv add django-cprofile-middlewarepoetry
poetry add django-cprofile-middlewareInstalling django-cprofile-middleware
Before you install
High install friction with no runtime dependencies. The package is abandoned—last commit was 2021-08-18 and last release 2020-02-20. No active maintenance or security updates.
License in practice
MIT license is permissive; you may use, modify, and distribute this package freely with minimal restrictions.
Quickstart
# Install
pip install django-cprofile-middleware
# In settings.py, add to MIDDLEWARE:
MIDDLEWARE = [
...,
'django_cprofile_middleware.middleware.ProfilerMiddleware'
]
# Then visit http://localhost:8000/your-view/?prof while logged in as staff
Requires Django with DEBUG=True and (by default) an authenticated user with is_staff=True; compatibility with modern Django and Python versions is unverified
Verify before relying
- Compatibility with modern Django versions (1.10+ middleware API is mentioned, but no upper bound specified)
- Python version support is unspecified; may not work with recent Python releases
- Whether the package works with Django's async views or only synchronous handlers
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | abandoned — 2,367 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 90,241/month — #13,609 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django-cprofile-middleware-1.0.5.tar.gz
Keywords: django, profiling, cProfile
Tags
More Quality Assurance packages
Coverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
ruffRuff is a Python linter and code formatter…
permissive · top 1,000 on PyPI
pexpectPexpect spawns and controls interactive console…
permissive · top 1,000 on PyPI
blackBlack reformats Python source code to a…
permissive · top 1,000 on PyPI
pytest-xdistpytest-xdist distributes pytest tests across…
permissive · top 1,000 on PyPI
cfn-lintValidates AWS CloudFormation templates in YAML…
permissive · top 1,000 on PyPI
django-silkSilk intercepts and profiles HTTP requests,…
permissive · top 5,000 on PyPI
fastapi-profilerIntegrates pyinstrument profiling into FastAPI…
permissive · top 15,000 on PyPI
pyprof2calltreeConverts Python cProfile profiling data into…
permissive · top 15,000 on PyPI
django-slowtestsIntegrates with Django's test runner to…
permissive · top 15,000 on PyPI
line-profilerline_profiler measures execution time on a…
permissive · top 5,000 on PyPI
pytest-profilingPytest plugin that profiles test execution…
permissive · top 5,000 on PyPI
flameprofConverts Python cProfile statistics into…
permissive · top 15,000 on PyPI
yappiYappi is a deterministic profiler for Python…
permissive · top 5,000 on PyPI
django-debug-toolbar-template-profilerAdds a debug panel to django-debug-toolbar that…
permissive · top 15,000 on PyPI
django-queryinspectDjango middleware that logs and reports SQL…
permissive · top 15,000 on PyPI