Reputation: 2011
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
Upvotes: 2
Views: 703
Reputation: 3230
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,
}
Upvotes: 4