Skip to content

Instantly share code, notes, and snippets.

@groovecoder
Created April 18, 2022 20:02
Show Gist options
  • Save groovecoder/5d2963d753cdfa690507a415b565dbaa to your computer and use it in GitHub Desktop.
Save groovecoder/5d2963d753cdfa690507a415b565dbaa to your computer and use it in GitHub Desktop.
add django-silk to Relay
diff --git a/privaterelay/settings.py b/privaterelay/settings.py
index 95396ca1..99345929 100644
--- a/privaterelay/settings.py
+++ b/privaterelay/settings.py
@@ -85,8 +85,8 @@ CSP_SCRIPT_SRC = (
'https://www.google-analytics.com/',
)
# TODO: Add with silk
-# if settings.DEBUG:
-# CSP_SCRIPT_SRC += ("'unsafe-inline'",)
+if settings.DEBUG:
+ CSP_SCRIPT_SRC += ("'unsafe-inline'",)
csp_style_values = ["'self'"]
# Next.js dynamically inserts the relevant styles when switching pages,
@@ -116,8 +116,8 @@ else:
CSP_STYLE_SRC = tuple(csp_style_values)
# TODO: Add with silk
-# if settings.DEBUG:
-# CSP_STYLE_SRC += ("'unsafe-inline'",)
+if settings.DEBUG:
+ CSP_STYLE_SRC += ("'unsafe-inline'",)
CSP_IMG_SRC = ["'self'"] + AVATAR_IMG_SRC
REFERRER_POLICY = 'strict-origin-when-cross-origin'
@@ -204,7 +204,7 @@ if DEBUG:
INSTALLED_APPS += [
'debug_toolbar',
'drf_yasg',
-# 'silk',
+ 'silk',
]
if ADMIN_ENABLED:
@@ -235,7 +235,7 @@ MIDDLEWARE = _get_initial_middleware()
if DEBUG:
MIDDLEWARE += [
-# 'silk.middleware.SilkyMiddleware',
+ 'silk.middleware.SilkyMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
]
@@ -695,3 +695,6 @@ markus.configure(
}
]
)
+
+SILKY_PYTHON_PROFILER=True
+SILKY_PYTHON_PROFILER_BINARY=True
diff --git a/privaterelay/urls.py b/privaterelay/urls.py
index 2336e17e..c33bfcf5 100644
--- a/privaterelay/urls.py
+++ b/privaterelay/urls.py
@@ -62,7 +62,7 @@ if settings.DEBUG:
urlpatterns += [
path('__debug__/', include(debug_toolbar.urls)),
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
-# path('silk/', include('silk.urls', namespace='silk')),
+ path('silk/', include('silk.urls', namespace='silk')),
]
if settings.ADMIN_ENABLED:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment