导入devserver模块devserver.modules.sql时出错:“无法导入名称util”

时间:2019-09-18 11:15:31

标签: python django python-2.7 django-dev-server

刚从Django 1.8升级到1.9,并在迁移时出现此错误:

导入devserver模块devserver.modules.sql时出错:“无法导入名称util”

尽管他们说它已在此处修复: https://github.com/dcramer/django-devserver/issues/131


[localhost] local: python manage.py migrate
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/halit/project_folder/.venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "/home/halit/project_folder/.venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 324, in execute
    django.setup()
  File "/home/halit/project_folder/.venv/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/halit/project_folder/.venv/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/home/halit/project_folder/.venv/local/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/halit/project_folder./venv/local/lib/python2.7/site-packages/devserver/models.py", line 40, in <module>
    load_modules()
  File "/home/halit/project_folder/.venv/local/lib/python2.7/site-packages/devserver/models.py", line 25, in load_modules
    raise exceptions.ImproperlyConfigured, 'Error importing devserver module %s: "%s"' % (name, e)
django.core.exceptions.ImproperlyConfigured: Error importing devserver module devserver.modules.sql: "cannot import name util"

Fatal error: local() encountered an error (return code 1) while executing 'python manage.py migrate'

Aborting.

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题。编辑usr / local / lib / python2.7 / dist-packages / devserver / modules / sql.py文件,并从以下位置更改第15行的导入:

from django.db.backends import util

from django.db.backends import utils

似乎要这样做。我必须将文件中的所有引用从util更改为utils