我正在尝试在我的django应用中使用django-degub-toolbar
,以下是我的settigns
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',
)
MIDDLEWARE_CLASSES += [
'debug_toolbar.middleware.DebugToolbarMiddleware',
]
INSTALLED_APPS += [
'debug_toolbar',
]
当我试图运行服务器时,我遇到错误
Validating models...
Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x32c8f10>>
Traceback (most recent call last):
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 92, in inner_run
self.validate(display_num_errors=True)
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/core/management/base.py", line 280, in validate
num_errors = get_validation_errors(s, app)
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/core/management/validation.py", line 35, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/db/models/loading.py", line 166, in get_app_errors
self._populate()
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/db/models/loading.py", line 72, in _populate
self.load_app(app_name, True)
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/db/models/loading.py", line 96, in load_app
models = import_module('.models', app_name)
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/user/.virtualenvs/proj/src/django-messages/django_messages/models.py", line 8, in <module>
User = get_user_model()
File "/home/user/.virtualenvs/proj/src/django-messages/django_messages/utils.py", line 93, in get_user_model
return get_user_model()
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/contrib/auth/__init__.py", line 125, in get_user_model
user_model = get_model(app_label, model_name)
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/db/models/loading.py", line 230, in get_model
self._populate()
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/db/models/loading.py", line 72, in _populate
self.load_app(app_name, True)
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/db/models/loading.py", line 96, in load_app
models = import_module('.models', app_name)
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/debug_toolbar/models.py", line 10, in <module>
from debug_toolbar.middleware import DebugToolbarMiddleware
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/debug_toolbar/middleware.py", line 13, in <module>
from debug_toolbar.toolbar import DebugToolbar
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/debug_toolbar/toolbar.py", line 153, in <module>
urlpatterns = DebugToolbar.get_urls()
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/debug_toolbar/toolbar.py", line 147, in get_urls
for panel_class in cls.get_panel_classes():
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/debug_toolbar/toolbar.py", line 125, in get_panel_classes
(panel_module, e))
django.core.exceptions.ImproperlyConfigured: Error importing debug panel debug_toolbar.panels.settings_vars: "No module named settings_vars"
如何解决以及遇到上述错误的原因?
答案 0 :(得分:20)
找不到settings_var
面板。您似乎使用旧版本的配置。面板最近已重命名,版本1.0的new configuration为:
DEBUG_TOOLBAR_PANELS = [
'debug_toolbar.panels.versions.VersionsPanel',
'debug_toolbar.panels.timer.TimerPanel',
'debug_toolbar.panels.settings.SettingsPanel',
'debug_toolbar.panels.headers.HeadersPanel',
'debug_toolbar.panels.request.RequestPanel',
'debug_toolbar.panels.sql.SQLPanel',
'debug_toolbar.panels.staticfiles.StaticFilesPanel',
'debug_toolbar.panels.templates.TemplatesPanel',
'debug_toolbar.panels.cache.CachePanel',
'debug_toolbar.panels.signals.SignalsPanel',
'debug_toolbar.panels.logging.LoggingPanel',
'debug_toolbar.panels.redirects.RedirectsPanel',
]