Skip to main content

Silky smooth profiling for the Django Framework — modernized UI fork of django-silk

Project description

django-silky

PyPI PyPI - Python Version Supported Django versions Tests PyPI - Downloads License: MIT

django-silky is a modernized-UI fork of django-silk — a live profiling and inspection tool for the Django framework.

It keeps 100 % of the original functionality (request/response recording, SQL inspection, code profiling, dynamic profiling) while shipping a fully redesigned interface built on CSS custom properties (light and dark mode), Lucide icons, an inline filter bar, multi-column sort chips, and proper pagination.


What's different from django-silk?

Feature django-silk django-silky
Theme Fixed dark nav, light body Full light/dark toggle, persisted in localStorage
Filter UI 300 px slide-out drawer Inline collapsible filter bar
Filter selectors Single-value dropdowns Multi-select for method, status code, and path (with search)
Sort Single column, GET param Multi-column sort chips (session-persisted)
Pagination Query-slice (LIMIT N) Real Django Paginator with prev/next/page numbers
Detail pages Plain tables Hero bar + metric pills + section cards
Icons Font Awesome (CDN) Lucide (self-hosted, no external requests)
URL sharing State lost on reload Sort + per-page encoded in URL; filter bar state in localStorage

Screenshots

Analytics dashboard – dark mode
Analytics dashboard — activity timeline, status donut, method lollipop, RT histogram, latency percentiles
Requests list with filter bar open
Inline filter bar — multi-select method, status, path chips; active filters shown inline
N+1 detection banner on SQL tab
N+1 detection — orange banner with query pattern, count badge, and total ms cost
N+1 highlighted query rows
N+1 highlighted rows — offending queries highlighted in the table
Request detail – dark mode
Request detail — hero bar with timing pills, query params, headers, response body, curl snippet
Profiling list – light mode
Profiling list — function name, duration, query count, DB time
SQL query detail – dark mode
SQL query detail — full query text, EXPLAIN plan, and Python stack trace
Profile detail – code view
Profile detail — source file, function code, and associated queries

Migrating from django-silk

django-silky is a drop-in replacement — same app label (silk), same database schema (migrations 0001 – 0008), all your existing data is retained.

pip uninstall django-silk
pip install django-silky
# No manage.py migrate needed — schema is identical

For full instructions, version compatibility details, and rollback steps see MIGRATING.md.


Requirements

  • Django 4.2, 5.1, 5.2, 6.0
  • Python 3.10, 3.11, 3.12, 3.13, 3.14

Installation

pip install django-silky

With optional request body formatting:

pip install django-silky[formatting]

settings.py

MIDDLEWARE = [
    ...
    'silk.middleware.SilkyMiddleware',
    ...
]

TEMPLATES = [{
    ...
    'OPTIONS': {
        'context_processors': [
            ...
            'django.template.context_processors.request',
        ],
    },
}]

INSTALLED_APPS = [
    ...
    'silk',
]

Middleware order: Any middleware placed before SilkyMiddleware that returns a response without calling get_response will prevent Silk from running. If you use django.middleware.gzip.GZipMiddleware, place it before SilkyMiddleware.

urls.py

from django.urls import include, path

urlpatterns += [
    path('silk/', include('silk.urls', namespace='silk')),
]

Migrate and collect static

python manage.py migrate
python manage.py collectstatic

The UI is now available at /silk/.


Features

Request Inspection

Silk's middleware records every HTTP request and response — method, status code, path, timing, SQL query count, and headers/bodies — and presents them in a filterable, sortable, paginated table.

SQL Inspection

Every SQL query executed during a request is captured with its execution time, tables involved, number of joins, and a full stack trace so you can see exactly where in your code it was triggered.

Code Profiling

Decorator / context manager

from silk.profiling.profiler import silk_profile

@silk_profile(name='View Blog Post')
def post(request, post_id):
    p = Post.objects.get(pk=post_id)
    return render(request, 'post.html', {'post': p})
def post(request, post_id):
    with silk_profile(name='View Blog Post #%d' % post_id):
        p = Post.objects.get(pk=post_id)
        return render(request, 'post.html', {'post': p})

cProfile integration

SILKY_PYTHON_PROFILER = True
SILKY_PYTHON_PROFILER_BINARY = True  # also save .prof files

When enabled, a call-graph coloured by time is shown on the profile detail page.

Dynamic profiling

Profile third-party code without touching its source:

SILKY_DYNAMIC_PROFILING = [{
    'module': 'path.to.module',
    'function': 'MyClass.bar',
}]

Code Generation

Silk generates a curl command and a Django test-client snippet for every request, making it easy to replay a captured request from the terminal or a unit test.


Configuration

Authentication

SILKY_AUTHENTICATION = True   # user must be logged in
SILKY_AUTHORISATION = True    # user must have is_staff=True (default)

# Custom permission check:
SILKY_PERMISSIONS = lambda user: user.is_superuser

Request / response body limits

SILKY_MAX_REQUEST_BODY_SIZE = -1    # -1 = no limit
SILKY_MAX_RESPONSE_BODY_SIZE = 1024 # bytes; larger bodies are discarded

Sampling (high-traffic sites)

SILKY_INTERCEPT_PERCENT = 50  # record only 50 % of requests
# or
SILKY_INTERCEPT_FUNC = lambda request: 'profile' in request.session

Garbage collection

SILKY_MAX_RECORDED_REQUESTS = 10_000
SILKY_MAX_RECORDED_REQUESTS_CHECK_PERCENT = 10  # GC runs on 10 % of requests

Trigger manually (e.g. from a cron job):

python manage.py silk_request_garbage_collect

Clear all data immediately:

python manage.py silk_clear_request_log

Query analysis

SILKY_ANALYZE_QUERIES = True
SILKY_EXPLAIN_FLAGS = {'format': 'JSON', 'costs': True}

Warning: EXPLAIN ANALYZE on PostgreSQL actually executes the query, which may cause unintended side effects. Use with caution.

Meta-profiling

SILKY_META = True  # shows how long Silk itself takes per request

Sensitive data masking

# Default set — case insensitive
SILKY_SENSITIVE_KEYS = {'username', 'api', 'token', 'key', 'secret', 'password', 'signature'}

Custom profiler storage

# Django >= 4.2
STORAGES = {
    'SILKY_STORAGE': {
        'BACKEND': 'path.to.StorageClass',
    },
}

SILKY_PYTHON_PROFILER_RESULT_PATH = '/path/to/profiles/'

Development

git clone https://github.com/VaishnavGhenge/django-silky.git
cd django-silky
python -m venv .venv && source .venv/bin/activate
pip install -e ".[formatting]"
pip install -r project/requirements.txt

# Run the example project
DB_ENGINE=sqlite3 python project/manage.py migrate
DB_ENGINE=sqlite3 python project/manage.py runserver
# Visit http://127.0.0.1:8000/silk/  (login: admin / admin)

# Watch SCSS while editing UI
npx gulp watch

# Run tests
DB_ENGINE=sqlite3 python -m pytest project/tests/ -q

Credits

django-silky is a fork of django-silk, originally created by Michael Ford and maintained by Jazzband. All core profiling functionality comes from the upstream project; this fork focuses solely on UI improvements.


License

MIT — same as the upstream django-silk.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_silky-1.1.0.tar.gz (7.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_silky-1.1.0-py3-none-any.whl (2.2 MB view details)

Uploaded Python 3

File details

Details for the file django_silky-1.1.0.tar.gz.

File metadata

  • Download URL: django_silky-1.1.0.tar.gz
  • Upload date:
  • Size: 7.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_silky-1.1.0.tar.gz
Algorithm Hash digest
SHA256 7148f0baefdab5e27140ea9e0a6461a963aaadf37a2f33445f70b09a05a04bf1
MD5 1a70903276ab30e198a1b546d4477b95
BLAKE2b-256 d2f1d28c15d096406a3d1467881e34ebdb69d4af147fad83b0b3ac96f6595414

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_silky-1.1.0.tar.gz:

Publisher: release.yml on VaishnavGhenge/django-silky

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_silky-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: django_silky-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_silky-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6f9e6d0dd13c2c4b4a9d66d5ebf45738aad324b65f91f3775c911c0238eb3980
MD5 17b1dba7ddd51574a4d6b064efe34761
BLAKE2b-256 6411b963d419767130d8df4f739c50936d922aee4bcb5a0e5d790302bb527578

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_silky-1.1.0-py3-none-any.whl:

Publisher: release.yml on VaishnavGhenge/django-silky

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page