Skip to content

Commit

Permalink
added django-silk as dev dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
opaduchak committed Jan 7, 2025
1 parent 3c1f84c commit 755a288
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 9 deletions.
17 changes: 10 additions & 7 deletions app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
# Application definition

INSTALLED_APPS = [
"silk",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
Expand All @@ -96,13 +95,7 @@
"addon_service",
]

if DEBUG:
# run under ASGI locally:
INSTALLED_APPS.insert(0, "daphne") # django's reference asgi server
ASGI_APPLICATION = "app.asgi.application"

MIDDLEWARE = [
"silk.middleware.SilkyMiddleware",
"corsheaders.middleware.CorsMiddleware",
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
Expand All @@ -113,6 +106,16 @@
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]


if DEBUG:
# add django-silk to enable profiling
INSTALLED_APPS.append("silk")
MIDDLEWARE.insert(0, "silk.middleware.SilkyMiddleware")
# run under ASGI locally:
INSTALLED_APPS.insert(0, "daphne") # django's reference asgi server
ASGI_APPLICATION = "app.asgi.application"


ROOT_URLCONF = "app.urls"

TEMPLATES = [
Expand Down
5 changes: 4 additions & 1 deletion app/urls.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.conf import settings
from django.contrib import admin
from django.urls import (
include,
Expand All @@ -14,5 +15,7 @@
RedirectView.as_view(url="/static/gravyvalet_code_docs/index.html"),
name="docs-root",
),
path("silk/", include("silk.urls", namespace="silk")),
]

if "silk" in settings.INSTALLED_APPS:
urlpatterns.append(path("silk/", include("silk.urls", namespace="silk")))
44 changes: 43 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ flake8 = "^7.1.1"
isort = "^5.13.2"
pre-commit = "^3.8.0"
pdoc = "14.5.1"
django-silk = "^5.3.2"

[tool.poetry.group.release.dependencies]
sentry-sdk = "2.7.1"
Expand Down

0 comments on commit 755a288

Please sign in to comment.