【发布时间】:2021-10-05 14:58:24
【问题描述】:
所以我试图将一个 django 应用程序部署到 heroku,它在本地运行良好。
虽然部署过程成功完成,但迁移命令出错。
django.db.migrations.exceptions.NodeNotFoundError: Migration accounts.0001_initial dependencies reference nonexistent parent node ('auth', '0013_alter_user_email')
这是我的迁移文件;
import accounts.models
from django.conf import settings
import django.contrib.gis.db.models.fields
from django.db import migrations, models
import django.db.models.deletion
from django.contrib.postgres.operations import CreateExtension
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('auth', '0013_alter_user_email'),
]
operations = [...]
从 cmets 中的讨论看来,0013_alter_user_email 迁移实际上并不存在于 auth 应用程序中。生成它是因为我在运行时使用User._meta.get_field('email').unique 访问它来修改用户模型以使电子邮件字段唯一。
【问题讨论】:
-
您是否尝试删除所有迁移,然后再次重新迁移??
-
是的,试过了。它在本地运行良好。
-
auth应用在哪里?您是否将其包含在您的部署中? -
它来自 django (django.contrib.auth)。所以我认为它应该与 django 一起安装
-
对不起,我没有。不过有一件事,您可以尝试将依赖关系更改为
0001的auth。我记得模糊地有一个类似的问题,它不会在本地发生。我通过使用它的第一次迁移首先加载依赖项来修复它。如果没有帮助,您可以显示迁移文件的其余部分吗?
标签: python django heroku deployment migrate