Skip to content

Instantly share code, notes, and snippets.

View rixx's full-sized avatar

Tobias Kunze rixx

View GitHub Profile
@rixx
rixx / debug.py
Last active May 16, 2025 10:24
Django: Start debugger on query
# Use: wrap methods:
# @breakpoint_on_query()
# Or use as `with breakpoint_on_query():`
from contextlib import contextmanager
@contextmanager
def breakpoint_on_query():
from django.db import connection
def instrument(execute, sql, params, many, context):
# Optional: match only specific queries, e.g.