MIDDLEWARE_CLASSES = [
    ...
    "django.contrib.sessions.middleware.SessionMiddleware",
    "debug_toolbar.middleware.DebugToolbarMiddleware",
    ...
]

def show_debug_toolbar(request):
    """Shows the debug toolbar based on the debug arg in the URL.
    
    ?debug=on - turns debugging on in the current session
    ?debug=off - turns debugging off in the current session
    """
    if DEBUG:
        debug = request.GET.get("debug", None)
        if debug == "on":
            request.session["debug"] = True
        elif debug == "off" and "debug" in request.session:
            del request.session["debug"]
        return "debug" in request.session
    
DEBUG_TOOLBAR_CONFIG = {
    "SHOW_TOOLBAR_CALLBACK": show_debug_toolbar,
}