djangodjango-silk

Disabling Django Silk for specific URLs


I have an API endpoint on which I can upload a photo using a multipart request. When Silk is trying to parse the request, I get a decoding error.

I now want to disable Silk for certain URL endpoints. Is this already possible? If so, how should I configure this? If not, what is the easiest way of temporarily disabling Silk altogether?

Link to Github issue: https://github.com/jazzband/django-silk/issues/292


Solution

  • It is not possible yet, but you can inherit from the Silk middleware and exclude some views from being silked using process_view django middleware method. E.g. class-based views in django has view_class attribute so you can figure out view class in middleware:

    def process_view(request, view_func, view_args, view_kwargs):
        if view_func.view_class == SomeClassBasedView:
            # ignore it
        else:
            return super().process_view(request, view_func, view_args, view_kwargs)
    

    The easiest way of temporarily disabling Silk altogether is removing it from middleware list.