Using django 2.2.14 and django-silk 3.0. Just return overall time but the queries are all 0.Is some wrong about the version of django-silk or django?How can I solve the bizarre issus.
Package Version Django 2.2.14 django-silk 3.0.2
[silk show image] enter image description here
Quick answer
Set SILKY_PYTHON_PROFILER_RESULT_PATH
in your settings.py
for example:
SILKY_PYTHON_PROFILER_RESULT_PATH = "/var/profiler"
You must ensure the specified directory exists. In the documentation of silk says It supposed to use media folder if it's not set but somehow is not working.
# If this is not set, MEDIA_ROOT will be used.
SILKY_PYTHON_PROFILER_RESULT_PATH = '/path/to/profiles/'
There are few things you need to ensure are set.
The main important one is adding the following env flags before your run your application.
In your .env
add:
SILKY_PYTHON_PROFILER=True
If you do have SILKY_INTERCEPT_FUNC
method in your settings.py
ensure it returns the correct boolean value based on the request eg
def SILKY_INTERCEPT_FUNC(request):
"""log only session has recording enabled."""
return 'record_requests' in request.session
In addition, ensure you add the silk middleware in the correct order
In settings.py
add the following:
MIDDLEWARE = [
...
'silk.middleware.SilkyMiddleware',
...
]
INSTALLED_APPS = (
...
'silk'
)
Note: The middleware placement is sensitive. If the middleware before silk.middleware.SilkyMiddleware returns from process_request then SilkyMiddleware will never get the chance to execute. Therefore you must ensure that any middleware placed before never returns anything from process_request. See the django docs for more information on this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.