Skip to content

Commit

Permalink
Add the ability to disable Django Silk
Browse files Browse the repository at this point in the history
  • Loading branch information
CamLamb committed Nov 29, 2024
1 parent ac799e7 commit 1fb5cda
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,8 @@ SEARCH_SHOW_INACTIVE_PROFILES_WITHIN_DAYS=90
# Manage apllication caching
SEARCH_ENABLE_QUERY_CACHE=False

# Django Silk
SILK_ENABLED=False

# Django Debug Toolbar
DDT_ENABLED=False
5 changes: 2 additions & 3 deletions src/config/settings/developer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"127.0.0.1",
]

try:
SILK_ENABLED = env.bool("SILK_ENABLED", False) # noqa F405
if SILK_ENABLED:
# Add django-silk for profiling
import silk # noqa F401

Expand All @@ -47,8 +48,6 @@
"profiler_results",
)
SILKY_META = True
except ModuleNotFoundError:
...


DEV_TOOLS_ENABLED = env.bool("DEV_TOOLS_ENABLED", True) # noqa F405
Expand Down
10 changes: 5 additions & 5 deletions src/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@
urlpatterns += [
path("dev-tools/", include("dev_tools.urls", namespace="dev_tools"))
]
if "debug_toolbar" in settings.INSTALLED_APPS:
# Django Debug Toolbar purposefully only active with DEBUG=True
from debug_toolbar.toolbar import debug_toolbar_urls

urlpatterns += debug_toolbar_urls()

urlpatterns += [
# Wagtail
path("", include(wagtail_urls)),
]

if settings.DEBUG and getattr(settings, "DDT_ENABLED", False):
# Django Debug Toolbar purposefully only active with DEBUG=True
from debug_toolbar.toolbar import debug_toolbar_urls

urlpatterns += debug_toolbar_urls()

# Removed until we find a fix for Wagtail's redirect behaviour
handler404 = "core.views.view_404"
Expand Down

0 comments on commit 1fb5cda

Please sign in to comment.