Django Silk

5.5.0 · active · verified Fri Apr 10

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.

Warnings

Install

Imports

Quickstart

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`.

# settings.py
INSTALLED_APPS = [
    # ... other apps
    'silk',
]

MIDDLEWARE = [
    # Place SilkyMiddleware near the top to capture full request cycle
    # If using GZipMiddleware, place it *before* SilkyMiddleware.
    # 'django.middleware.gzip.GZipMiddleware',
    'silk.middleware.SilkyMiddleware',
    # ... other middleware
]

# Optional: Restrict access to Silk UI
# SILKY_AUTHENTICATION = True # Requires user to be logged in
# SILKY_AUTHORISATION = True  # Requires logged-in user to be staff
# LOGIN_URL = '/admin/login/' # Example for custom login URL if SILKY_AUTHENTICATION is True

# urls.py
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('silk/', include('silk.urls', namespace='silk')),
    # ... other url patterns
]

# After configuration, run migrations:
# python manage.py migrate
# Access the UI at /silk/

view raw JSON →