Skip to content

middleware.py

Middleware using query_capture available in django

QueryCaptureMiddleware ยค

Capture all queries that occur when one request occurs and output them to the console.

Source code in django_query_capture/middleware.py
class QueryCaptureMiddleware:
    """
    Capture all queries that occur when one request occurs and output them to the console.
    """

    def __init__(self, get_response):
        self.get_response = get_response

    @query_capture()
    def __call__(self, request):
        return self.get_response(request)