Skip to content

Instantly share code, notes, and snippets.

@generalov
Created July 7, 2016 09:47
Show Gist options
  • Save generalov/7090c0c0d0ab1ca7c0c25776736c707f to your computer and use it in GitHub Desktop.
Save generalov/7090c0c0d0ab1ca7c0c25776736c707f to your computer and use it in GitHub Desktop.
Toggle django-debug-toolbar with Xdebug-helper Chrome extension.
# Install https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc
# then add this to your django project settings.py
def show_toolbar(request):
"""
Default function to determine whether to show the toolbar on a given page.
"""
from django.conf import settings
# if request.META.get('REMOTE_ADDR', None) not in settings.INTERNAL_IPS:
# return False
if request.is_ajax():
return False
if any(x in request.COOKIES for x in ['XDEBUG_SESSION', 'XDEBUG_PROFILE', 'XDEBUG_TRACE']):
return bool(settings.DEBUG)
return False
DEBUG_TOOLBAR_CONFIG = {
'SHOW_TOOLBAR_CALLBACK': show_toolbar
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment