skillfed

django-cprofile-middleware

Easily add cProfile profiling to django views.

django-cprofile-middleware v1.0.5 90.2K downloads/30d#13,609 on PyPI153
Permissive license MIT Abandoned released

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-middleware

uv

uv add django-cprofile-middleware

poetry

poetry add django-cprofile-middleware

Installing 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

Framework :: Django

Tags

django view profilingcprofile middleware djangodjango performance bottleneckdjango request profilingdjango debug profilerdjango view timingdjango performance analysis
django-profilingdevelopment-onlyabandoned

More Quality Assurance packages