运行迁移时Django 1.9 ImportError,但不是runserver

时间:2016-01-09 21:46:17

标签: django virtualenv django-settings django-migrations cookiecutter-django

我正在尝试在新的Django 1.9项目上运行新的迁移,但我收到的ImportError似乎与 runserver 冲突。我正在从< project>运行这些命令。包含manage.py文件的目录。

详细说明:

  • Django 1.9
  • 使用cookiecutter-django
  • runserver 引用设置文件
  • 迁移会产生导入错误
  • 在我的本地.env文件中,我有DJANGO_SETTINGS_MODULE = config.settings.local
  • 设置位于< project> / config / settings /...
  • 我在virtualenv
  • 中运行该项目

命令&错误:

$ django-admin.py migrate --settings=config.settings.local
.....
ImportError: No module named config.settings.local



$ python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).

You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.

January 09, 2016 - 13:33:32
Django version 1.9, using settings 'config.settings.local'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

有什么想法吗?提前致谢!

1 个答案:

答案 0 :(得分:2)

使用manage.py代替django-admin.py

python manage.py migrate --settings=config.settings.local