3👍
It’s generally considered bad practice to use the built-in admin backend for end-users.
Try checking foy <body></body>
tags in the pages. Without these it will not load.
Then try adding INTERNAL_IPS = (‘127.0.0.1’) in settings.py
To make it ONLY load for users inside the admin panel, you could add a tag to your custom admin pages and change settings.DEBUG_TOOLBAR_CONFIG['INSERT_BEFORE']
Docs: here
Last to force it to show everywhere, you can try adding this to the settings file:
def show_toolbar(request):
return True
DEBUG_TOOLBAR_CONFIG = {
"SHOW_TOOLBAR_CALLBACK" : show_toolbar,
}
to stop debug toolbar from checking if it should appear or not, it always will Only use for testing/development purposes. All other users can see it as well.
Documentation: here.
0👍
A quick overview over what I had to do to get debug_toolbar and admin working together.
You want to load jquery on its own, even though requireJS is configured to handle it as well.
From https://github.com/django-debug-toolbar/django-debug-toolbar/issues/605 :
settings.py
DEBUG_TOOLBAR_CONFIG = {
"JQUERY_URL": None,
}
Now, set up the admin to load jquery outside of requireJS, so debug toolbar can find it:
I was planning to customize that admin anyway, so no big deal creating a base_site.html override.
/myproj/templates/admin/base_site.html
{% block extrahead %}
*************** add this (with proper path) ************************
<script type="text/javascript" src="{{STATIC_URL}}websec/external/jquery-2.1.1.min.js"></script>
*******************************************************************
<script type="text/javascript" src="{{STATIC_URL}}websec/external/require.js"></script>
<script>
{% include "websec/requirejs_config.html" %}
require(['bootstrap'], function(bootstrap){
});
</script>
{% endblock %}
This is similar to what I had to do to my site’s ancestor template to get debug_toolbar and requireJS to cohabit:
/myproj/templates/websec/__base.html
{% block requirejs %}
<script type="text/javascript" src="/static/websec/external/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="{{STATIC_URL}}websec/external/require.js"></script>
<script>
//defines the requirejs configuration in general.
{% include "websec/requirejs_config.html" %}
</script>
{% endblock requirejs %}
Unrelated, but a nice hack to get rid of debug_toolbar during unit testing:
settings.py
INSTALLED_APPS = (
'django.contrib.auth',
#... more stuff
'debug_toolbar',
'myapp',
'djcelery',
'crispy_forms',
)
#hack, but debug toolbar totally collapses performance on some tests
pgm = os.path.basename(sys.argv[0])
if pgm.startswith("test") or pgm.startswith("nosetests"):
li = [app for app in INSTALLED_APPS if not app == "debug_toolbar"]
INSTALLED_APPS = tuple(li)
- [Django]-IP address for django-axes logins does not show
- [Django]-Django get rid of duplicated queries in nested models
- [Django]-Django – AJAX-SELECT 403 Forbidden