Skip to content

Commit 1fd2c4f

Browse files
authored
Merge pull request #626 from jazzband/269-installed-check
#269 Better check whether app is installed
2 parents 3fc0432 + db4e57f commit 1fd2c4f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

silk/profiling/profiler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import traceback
55
from functools import wraps
66

7+
from django.apps import apps
78
from django.conf import settings
89
from django.utils import timezone
910

@@ -122,12 +123,11 @@ def __exit__(self, exc_type, exc_val, exc_tb):
122123
self._finalise_queries()
123124

124125
def _silk_installed(self):
125-
app_installed = 'silk' in settings.INSTALLED_APPS
126126
middlewares = getattr(settings, 'MIDDLEWARE', [])
127127
if not middlewares:
128128
middlewares = []
129129
middleware_installed = SilkyConfig().SILKY_MIDDLEWARE_CLASS in middlewares
130-
return app_installed and middleware_installed
130+
return apps.is_installed('silk') and middleware_installed
131131

132132
def _should_profile(self):
133133
return DataCollector().request is not None

silk/templates/silk/profiling.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,14 @@ <h2>Silk Profiler</h2>
247247
<div class="container">
248248
<h2>Silk Profiler</h2>
249249

250-
<div class="description">No Silk profiling was performed for this request. Use the silk_profile
251-
decorator/context manager to do so.
250+
<div class="description">
251+
No Silk profiling was performed for this request. Please check that:
252+
<ul>
253+
<li>you use the <code>@silk_profile</code> decorator or <code>with silk_profile():</code> context manager on the correct view</li>
254+
<li>you have <code>"silk"</code> in <code>INSTALLED_APPS</code></li>
255+
<li>you have <code>"silk.middleware.SilkyMiddleware"</code> in <code>MIDDLEWARE</code></li>
256+
<li>you have <code>SILKY_PYTHON_PROFILER</code> set to <code>True</code></li>
257+
</ul>
252258
</div>
253259
</div>
254260
{% endif %}

0 commit comments

Comments
 (0)