Django Silk is a live profiling and inspection tool for the Django framework, designed to help developers identify performance bottlenecks. It intercepts and stores HTTP requests, responses, and database queries, presenting them in an intuitive user interface for detailed analysis. Currently at version 5.5.0, it maintains an active release cadence, supporting recent Django and Python versions.
pip install django-silkVerified import paths — ran on the pinned version, not inferred.
To quickly set up Django Silk, add 'silk' to `INSTALLED_APPS` and 'silk.middleware.SilkyMiddleware' to `MIDDLEWARE` in your Django settings. It's crucial to place `SilkyMiddleware` early in your `MIDDLEWARE` list to capture the entire request/response cycle; if using `GZipMiddleware`, place it before `SilkyMiddleware`. Finally, include 'silk.urls' in your project's `urls.py` and run `python manage.py migrate`.
Upgrade Python to 3.10+ and Django to 4.2+ or pin django-silk to a version prior to 5.3.0 (e.g., `django-silk==5.2.0`).
Migrate your storage configuration from `SILKY_STORAGE_CLASS` to the `STORAGES` setting as per Django's official documentation.
Place `silk.middleware.SilkyMiddleware` as high as possible in your `MIDDLEWARE` list. Ensure `django.middleware.gzip.GZipMiddleware` is positioned before it if used.
Restrict Django Silk to development and staging environments. Use environment variables or Django settings to enable/disable it conditionally.
Ensure you are on the latest patch release (e.g., 5.4.3 or newer) and thoroughly test profiling with custom binary or JSON fields. Report any new issues to the maintainers.
Be aware of this limitation when profiling in multi-threaded or concurrent environments with Python 3.12+. Consider other profiling approaches for concurrent code sections if precise timing is needed across concurrent operations.