Skip to content

Instantly share code, notes, and snippets.

@readevalprint
Created May 5, 2020 16:57
Show Gist options
  • Save readevalprint/7208c9e07f6ab391a8d9ac0908654f9c to your computer and use it in GitHub Desktop.
Save readevalprint/7208c9e07f6ab391a8d9ac0908654f9c to your computer and use it in GitHub Desktop.
def show_debug_toolbar(request):
if request.__class__.__name__ == "AsgiRequest":
return (
b"DEBUG" in request.scope["query_string"]
or "djdt=show" in request.META.get("HTTP_COOKIE", "")
) and (DEBUG or request.user.is_superuser)
s = (
"DEBUG" in request.environ.get("QUERY_STRING", "")
or "djdt=show" in request.environ.get("HTTP_COOKIE", "")
) and (DEBUG or request.user.is_superuser)
return s
DEBUG_TOOLBAR_CONFIG = {"SHOW_TOOLBAR_CALLBACK": show_debug_toolbar}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment