I have installed python 2.7 and django 1.4 in my centos machine and installed all dependencies for my existing project.When i run "python manage.py runserver" i am getting the following traceback in my console.
我在我的centos机器上安装了python 2.7和django 1.4并为我现有的项目安装了所有依赖项。当我运行“python manage.py runserver”时,我在我的控制台中获得了以下回溯。
[root@localhost bv]# python manage.py runserver
Validating models...
Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x8ddd7ec>>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 91, in inner_run
self.validate(display_num_errors=True)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 266, in validate
num_errors = get_validation_errors(s, app)
File "/usr/local/lib/python2.7/site-packages/django/core/management/validation.py", line 30, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/usr/local/lib/python2.7/site-packages/django/db/models/loading.py", line 158, in get_app_errors
self._populate()
File "/usr/local/lib/python2.7/site-packages/django/db/models/loading.py", line 67, in _populate
self.load_app(app_name)
File "/usr/local/lib/python2.7/site-packages/django/db/models/loading.py", line 88, in load_app
models = import_module('.models', app_name)
File "/usr/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.7/site-packages/debug_toolbar/models.py", line 6, in <module>
from debug_toolbar.toolbar.loader import load_panel_classes
File "/usr/local/lib/python2.7/site-packages/debug_toolbar/toolbar/loader.py", line 12, in <module>
from debug_toolbar.utils.settings import CONFIG
File "/usr/local/lib/python2.7/site-packages/debug_toolbar/utils/__init__.py", line 9, in <module>
from django.utils.encoding import force_text
ImportError: cannot import name force_text
1 个解决方案
#1
6
Upgrade to the latest Django 1.4 (as of 07-08-2014 - the "1.4.13").
升级到最新的Django 1.4(截至2014年7月7日 - “1.4.13”)。
I see that they have added a shortcut (force_text
) in the django.utils.encoding
module: https://github.com/django/django/blob/stable/1.4.x/django/utils/encoding.py
我看到他们在django.utils.encoding模块中添加了一个快捷方式(force_text):https://github.com/django/django/blob/stable/1.4.x/django/utils/encoding.py
Note, that the shortcut wasn't there in the initial 1.4 version (https://github.com/django/django/blob/1.4/django/utils/encoding.py) and was only added in 1.4.2 (https://github.com/django/django/blob/1.4.2/django/utils/encoding.py).
请注意,最初的1.4版本(https://github.com/django/django/blob/1.4/django/utils/encoding.py)中没有该快捷方式,并且仅在1.4.2中添加了该快捷方式(https: //github.com/django/django/blob/1.4.2/django/utils/encoding.py)。
As stated in the docs of django-debug-toolbar
, current version (as of 07-08-2014 - the "1.2.1") works fine on Django 1.4 to 1.7.
正如django-debug-toolbar的文档中所述,当前版本(截至2014年7月7日 - “1.2.1”)在Django 1.4到1.7上运行良好。
Thus, make sure you use latest version of Django
1.4.x and django-debug-toolbar
.
因此,请确保使用最新版本的Django 1.4.x和django-debug-toolbar。
#1
6
Upgrade to the latest Django 1.4 (as of 07-08-2014 - the "1.4.13").
升级到最新的Django 1.4(截至2014年7月7日 - “1.4.13”)。
I see that they have added a shortcut (force_text
) in the django.utils.encoding
module: https://github.com/django/django/blob/stable/1.4.x/django/utils/encoding.py
我看到他们在django.utils.encoding模块中添加了一个快捷方式(force_text):https://github.com/django/django/blob/stable/1.4.x/django/utils/encoding.py
Note, that the shortcut wasn't there in the initial 1.4 version (https://github.com/django/django/blob/1.4/django/utils/encoding.py) and was only added in 1.4.2 (https://github.com/django/django/blob/1.4.2/django/utils/encoding.py).
请注意,最初的1.4版本(https://github.com/django/django/blob/1.4/django/utils/encoding.py)中没有该快捷方式,并且仅在1.4.2中添加了该快捷方式(https: //github.com/django/django/blob/1.4.2/django/utils/encoding.py)。
As stated in the docs of django-debug-toolbar
, current version (as of 07-08-2014 - the "1.2.1") works fine on Django 1.4 to 1.7.
正如django-debug-toolbar的文档中所述,当前版本(截至2014年7月7日 - “1.2.1”)在Django 1.4到1.7上运行良好。
Thus, make sure you use latest version of Django
1.4.x and django-debug-toolbar
.
因此,请确保使用最新版本的Django 1.4.x和django-debug-toolbar。