django-silk icon indicating copy to clipboard operation
django-silk copied to clipboard

SILKY_IGNORE_PATHS should ignore path without SCRIPT_NAME path prefix

Open shimizukawa opened this issue 5 years ago • 2 comments

The settings.SILKY_IGNORE_PATHS (undocumented) config ignore paths https://github.com/jazzband/django-silk/blob/4418b29d23bff2a34edb4310a6472dcf2805eb83/silk/middleware.py#L47

If specified settings.SILKY_IGNORE_PATHS (undocumented) matches the request.path exactly, it will be excluded from recording. However, since it uses request.path as the matching condition, the path will have the path prefix passed from the web front server (apache/nginx). This may or may not match depending on the web front server configuration.

I think django-silk should use request.path_info to avoid this problem. https://docs.djangoproject.com/en/2.2/ref/request-response/#django.http.HttpRequest.path_info

shimizukawa avatar Jun 16 '19 08:06 shimizukawa

Yes that is indeed an issue, @shimizukawa did you find any possible solution?

subodhk01 avatar Jan 23 '22 09:01 subodhk01

I think a simple solution would be to change the ignore condition. In my case, I want to ignore all paths that contain admin string. ignored = any(path in request.path for path in config.SILKY_IGNORE_PATHS)

Korben11 avatar Feb 17 '22 17:02 Korben11