正如标题中所述,运行python manage.py migrate
会运行迁移,但app目录中不会生成任何迁移目录,因此不存在来自models.py
的表。
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying auth.0010_alter_group_name_max_length... OK
Applying auth.0011_update_proxy_permissions... OK
Applying sessions.0001_initial... OK
对我来说这是一个很新的错误。我该怎么办?
答案 0 :(得分:3)
python manage.py migrate
仅运行现有的迁移,不会进行新的迁移。您正在寻找的可能是python manage.py makemigrations
。
答案 1 :(得分:0)
您应该检查您的migrations
目录中是否包含空的__init__.py
文件。然后在INSTALLED_APP中(在settings.py中)添加您的应用名称(或应用地址),然后使用python manage.py makemigrations
制作迁移文件。
现在您可以使用迁移命令了!
答案 2 :(得分:0)
您可以尝试:
python manage.py migrate 'yourappname'
或者:
python manage.py makemigrations 'yourappname'