【问题标题】:Can not install django-debug-toolbar for Django 1.9无法为 Django 1.9 安装 django-debug-toolbar
【发布时间】:2016-04-08 04:16:59
【问题描述】:

我有 django 1.9 的 PIP INSTALL 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、在INSTALLED_APPS中添加debug_toolbar;

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 操作系统上所做的一切,作为我的测试。

有人能找出我的错误步骤吗?非常感谢。

【问题讨论】:

  • 你有想过这个吗?
  • 还没有。最近我不关注这个问题,我以后会关心网站性能
  • 好的,谢谢。我也没升级。 1.9 在错误之后抛出错误。

标签: python django django-debug-toolbar django-1.9


【解决方案1】:

请尝试pip freeze 并检查django-debug-toolbar 是否安装正确。在 Windows 中,您应该以管理员身份在 CMD 或 virtualenv 中安装 pypi 包。否则 Windows 不会让你通过 pip 安装包。

【讨论】:

  • 感谢您的回答,我尝试了 pip freeze,它表明我已经成功安装了工具栏
【解决方案2】:

在为 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.另外你的模板应该有封闭的body标签。

现在它应该适用于 Django 1.9。

【讨论】:

    猜你喜欢
    • 2015-05-13
    • 1970-01-01
    • 2013-01-15
    • 2021-07-15
    • 2022-08-13
    • 2019-12-13
    • 2011-08-05
    • 2016-06-01
    • 1970-01-01
    相关资源
    最近更新 更多