我为django 1.9安装了PIP安装DJANGO-DEBUG-TOOLBAR,这是我PYTHON MANAGE.PY RUNSERVER时的错误信息:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 350, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 176, in fetch_command
commands = get_commands()
File "C:\Python27\lib\site-packages\django\utils\lru_cache.py", line 100, in wrapper
result = user_function(*args, **kwds)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 71, in get_commands
for app_config in reversed(list(apps.get_app_configs())):
File "C:\Python27\lib\site-packages\django\apps\registry.py", line 137, in get_app_configs
self.check_apps_ready()
File "C:\Python27\lib\site-packages\django\apps\registry.py", line 124, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
我所做的如下:
1,pip install django-debug-toolbar;
2,将debug_toolbar添加到INSTALLED_APPS;
3,将'debug_toolbar.middleware.DebugToolbarMiddleware'添加到'MIDDLEWARE_CLASSES';
4,将'DEBUG_TOOLBAR_PANELS'放入setting.py文件;
5,设置DEGUG = True,并设置DEBUG_TOOLBAR_PATCH_SETTINGS = False;
6,正如官方文件所说,放if settings.DEBUG:
import debug_toolbar
urlpatterns += patterns('',
url(r'^__debug__/', include(debug_toolbar.urls)),
)
进入urls.py
7,我在WINDOWS 10 os上完成的所有测试。
有人可以弄清楚我的错误步骤吗?非常感谢。
答案 0 :(得分:1)
请尝试pip freeze
并检查django-debug-toolbar
是否安装正确。在Windows中,您应该以管理员或virtualenv的身份在CMD中安装pypi软件包。否则,Windows将不允许您通过pip安装软件包。
答案 1 :(得分:0)
在为Django 1.9.8安装django-debug-toolbar时也遇到了问题:
这些是帮助我的步骤:
1.pip install django-debug-toolbar;
2.这是我的dev.py(删除设置):
"""Development settings and globals."""
from .base import *
# DEBUG CONFIGURATION
DEBUG = True
MIDDLEWARE_CLASSES += ['debug_toolbar.middleware.DebugToolbarMiddleware', ]
INSTALLED_APPS += ['debug_toolbar', ]
INTERNAL_IPS = ['127.0.0.1', '10.0.2.2', ]
DEBUG_TOOLBAR_CONFIG = {
'DISABLE_PANELS': [
'debug_toolbar.panels.redirects.RedirectsPanel',
],
'SHOW_TEMPLATE_CONTEXT': True,
}
3.这是我的urls.py
from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
]
if settings.DEBUG:
if 'debug_toolbar' in settings.INSTALLED_APPS:
import debug_toolbar
urlpatterns = [
url(r'^__debug__/', include(debug_toolbar.urls)),
] + urlpatterns
4.此外,您的模板应该包含正文标记。
现在它应该适用于Django 1.9。