2

I have a virtual machine and i have dedicated it a static IP for local usage. 192.168.1.23 I have django running on the VM on 127.0.0.1:8000. I install django-debug-toolbar on the app and then apply the following settings:

DEBUG = True

INSTALLED_APPS += (
    'debug_toolbar',
)

INTERNAL_IPS = ('127.0.0.1', '192.168.1.23')

DEBUG_TOOLBAR_CONFIG = {'INTERCEPT_REDIRECTS': False,}

MIDDLEWARE_CLASSES += (
    'debug_toolbar.middleware.DebugToolbarMiddleware',
)

DEBUG_TOOLBAR_PANELS = (
    'debug_toolbar.panels.version.VersionDebugPanel',
    'debug_toolbar.panels.timer.TimerDebugPanel',
    'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
    'debug_toolbar.panels.headers.HeaderDebugPanel',
    'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
    'debug_toolbar.panels.template.TemplateDebugPanel',
    'debug_toolbar.panels.sql.SQLDebugPanel',
    'debug_toolbar.panels.signals.SignalDebugPanel',
    'debug_toolbar.panels.logger.LoggingPanel',
)

I am not able to see it either in admin or in website. What possibly might be wrong? There are not HTML issues and the page has a body tag. What can be the possible error?

EDIT: request.META['REMOTE_ADDR'] is 127.0.0.1

user1629366
  • 1,931
  • 5
  • 20
  • 30
  • May be something is wrong with middleware ordering? In docs: "Be aware of middleware ordering and other middleware that may intercept requests and return responses. Putting the debug toolbar middleware after the Flatpage middleware, for example, means the toolbar will not show up on flatpages." – demalexx Sep 11 '12 at 08:44
  • Can you try 0) `('127.0.0.1', '192.168.1.23', '')` and 1) `print request.META['REMOTE_ADDR']` – jpic Sep 11 '12 at 08:48
  • Not - 192.168.1.23 but 192.168.1.25 or whatver is your browser's ip. – Jure C. Sep 11 '12 at 08:55

1 Answers1

4

This is working for me where XXX is the desired IP-Adress:

def custom_show_toolbar(request):
    if request.META['REMOTE_ADDR'] == 'XXX.XXX.XXX.XXX':
        return True
    else:
        return False

DEBUG_TOOLBAR_CONFIG = {
    'SHOW_TOOLBAR_CALLBACK': custom_show_toolbar,
    'INTERCEPT_REDIRECTS': False,
    }

Update: As of version 1.0, SHOW_TOOLBAR_CALLBACK should be a dotted path, so the setting looks more like:

DEBUG_TOOLBAR_CONFIG = {
    'SHOW_TOOLBAR_CALLBACK': 'dotted.path.to.custom_show_toolbar',
    'INTERCEPT_REDIRECTS': False,
}
Community
  • 1
  • 1
Jingo
  • 3,200
  • 22
  • 29