尝试安装django调试工具栏并收到以下错误:
Traceback (most recent call last):
File "/home/user/project/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/user/project/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/home/user/project/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "/home/user/project/env/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/user/project/env/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/user/project/env/local/lib/python2.7/site-packages/django/apps/config.py", line 86, in create
module = import_module(entry)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named analysisdebug_toolbar
包装版本:
Django==1.8.2
django-debug-toolbar==1.3.0
有趣的是,这种情况过去常常起作用,但由于项目的某些变化而导致某种程度上破裂。
答案 0 :(得分:2)
您的INSTALLED_APPS
设置中似乎缺少逗号。
而不是:
INSTALLED_APPS = (
...
'analysis'
'debug_toolbar',
...
)
应该是:
INSTALLED_APPS = (
...
'analysis',
'debug_toolbar',
...
)
当您忘记逗号时,Python会将'analysis'
和'debug_toolbar'
连接到字符串analysisdebug_toolbar
中。在Python中,最好在列表或元组的最后一个元素中包含一个尾随逗号。它允许您添加新项目或重新排列顺序,而不会遇到这样的错误。