在django中使用makemigration时出错

时间:2017-10-10 10:57:52

标签: django migration python-3.5 makemigrations

我正在使用运行python3.5的开发服务器和使用virtualenv的django 1.11

当我使用“ python manage.py makemigrations ”时,我收到此错误

Traceback (most recent call last): File "manage.py", line 8, in <module> from django.core.management import execute_from_command_line File "/opt/hafez_bot/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 13, in <module> from django.core.management.base import ( File "/opt/hafez_bot/env/lib/python3.5/site-packages/django/core/management/base.py", line 17, in <module> from django.db.migrations.exceptions import MigrationSchemaMissing File "/opt/hafez_bot/env/lib/python3.5/site-packages/django/db/migrations/__init__.py", line 1, in <module> from .migration import Migration, swappable_dependency # NOQA ImportError: No module named 'django.db.migrations.migration'

请帮帮我

我知道这是关于我的“ manage.py ”文件,它与迁移无关。因为“python manage.py help”会引发同样的错误

这是我的“ pip freeze ”输出:

certifi==2017.7.27.1
Django==1.11.6
djangorestframework==3.6.4
future==0.16.0
mysqlclient==1.3.12
python-telegram-bot==8.0
pytz==2017.2

2 个答案:

答案 0 :(得分:2)

我删除了django并重新安装了它。 错误已修复

答案 1 :(得分:0)

我也学到了一个艰难的教训和宝贵的教训,任何时候你都可能面对django提出的挑战,底部的一条线有以下组件ImportError: No module named 'django.db.migrations.migration'你会注意到django安装不好。因此,您将被迫再次重新安装django,以便可以使用所有模型迁移文件进行迁移。