不能得到django-debug-toolbar出现 [英] Cannot get django-debug-toolbar to appear
问题描述
无论我做什么,我根本无法获得django-debug-toolbar出现。我已经尝试过这个问题的每一个答案上的建议。
No matter what I do, I simply cannot get django-debug-toolbar to appear. I've tried everything suggested in every answer on this question.
- 我的设置中有
DEBUG = True
- 我在
INSTALLED_APPS $中有
django.contrib.staticfiles
和debug_toolbar
c $ c> - 我有
'debug_toolbar.middleware.DebugToolbarMiddleware'
在MIDDLEWARE_CLASSES
- 我的设置中有
INTERNAL_IPS =()
- 在视图中添加
print(调试工具栏的IP地址+ request.META ['REMOTE_ADDR'])
,并打印IP地址对于调试工具栏:127.0.0.1
- 我有一个关闭
< / body>< / html>
在我的模板中 - 我已经在我的virtualenv中运行
pip install django-debug-toolbar
,没有任何问题>
- 我已经运行了
python manage.py collectstatic
,并且在我的...中有一个debug_toolbar
目录静态文件
- I have
DEBUG=True
in my settings - I have
django.contrib.staticfiles
anddebug_toolbar
inINSTALLED_APPS
- I have
'debug_toolbar.middleware.DebugToolbarMiddleware'
high up inMIDDLEWARE_CLASSES
- I have
INTERNAL_IPS = ()
in my settings - I tried adding
print("IP Address for debug-toolbar: " + request.META['REMOTE_ADDR'])
in a view, and it printedIP Address for debug-toolbar: 127.0.0.1
- I have a closing
</body></html>
in my template - I have run
pip install django-debug-toolbar
in my virtualenv, without any issues - I have run
python manage.py collectstatic
and there is adebug_toolbar
directory in my static files
当我运行应用程序时,我看不到任何请求控制台包含django_debug_toolbar的任何网址,因此我怀疑这是应用程序未加载。
When I run the app, I see no request in the console for any URLs containing django_debug_toolbar, so I suspect it's the application not being loaded.
我也没有在开发者控制台中看到任何失败的请求。
I don't see any failed requests in the developer console, either.
我已经阅读了 django-debug-toolbar安装文档,并没有提出想法。
I've read the django-debug-toolbar installation docs and am out of ideas.
有没有人有任何调试建议?我正在运行OSX和Django 1.7。好奇的是,调试工具栏WAS出现很好 - 我想我做了一些调整,导致它消失了,但我不知道什么。
Does anyone have any suggestions for debugging? I'm running OSX and Django 1.7. The curious thing is that debug-toolbar WAS appearing just fine - I think I've made some tweak that caused it to vanish, but I don't know what.
更新:我甚至尝试在我的设置文件中添加,这应该强制工具栏出现:
UPDATE: I've even tried adding this in my settings file, which is supposed to force the toolbar to appear:
def show_toolbar(request):
return True
SHOW_TOOLBAR_CALLBACK = show_toolbar
但它没有帮助。
我也尝试在我的视图中抛出一个故意的异常,所以我可以检查DEBUG是否开启,所有设置如上。他们是,但仍然没有工具栏!
I've also tried throwing a deliberate exception in my view, so that I can check DEBUG is on and all the settings are as above. They are, and still no toolbar!
更新2:当我设置 INTERNAL_IPS =('127.0.0.1',)
,我开始在控制台中看到调试工具栏请求,但在页面上没有工具栏。
UPDATE 2: When I set INTERNAL_IPS=('127.0.0.1',)
, I start to see debug-toolbar requests in the console, but no toolbar on the page.
以下HTML出现在我的页面中 - 所以工具栏在那里,但是它不可见,因为它有 display = none
设置它:
And the following HTML appears in my page - so the toolbar is there, but it's not visible because it's got display=none
set all over it:
推荐答案
所有带的div都显示:none;
其实行为正常。他们不会更改为 display:block;
,直到您在工具栏本身中实际点击它们。
All of the divs with display: none;
are in fact behaving properly. They won't change to display: block;
until you actually click on them in the toolbar itself.
用于切换工具栏的按钮是带有 id =djDebugToolbarHandle
的div。正如您在控制台中可以看到的,此按钮具有顶部
位置 2310px
。这意味着它是呈现,但它只是在页面下方。
The button used to toggle the toolbar is the div with an id="djDebugToolbarHandle"
. As you can see in your console, this button has a top
position of 2310px
. What this means is that it is rendering, but it is just way down off the page.
尝试在控制台中键入以下内容以重置其位置:
Try typing the following in the console to reset its position:
document.getElementById('djDebugToolbarHandle').style.top="30px";
这篇关于不能得到django-debug-toolbar出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!