Skip to content

Instantly share code, notes, and snippets.

View TechStuffBoy's full-sized avatar
🎯
Focusing

Nandha Kumar M TechStuffBoy

🎯
Focusing
View GitHub Profile
@vstoykov
vstoykov / SQLPrintingMiddleware.py
Last active December 2, 2022 07:18
Django Middleware to print sql queries in debug console
"""
Originaly code was taken from http://djangosnippets.org/snippets/290/
But I was made some improvements like:
- print URL from what queries was
- don't show queries from static URLs (MEDIA_URL and STATIC_URL, also for /favicon.ico).
- If DEBUG is False tell to django to not use this middleware
- Remove guessing of terminal width (This breaks the rendered SQL)
"""
from django.core.exceptions import MiddlewareNotUsed
from django.conf import settings