【发布时间】:2019-03-29 12:51:26
【问题描述】:
我试图让用户在 Heroku 上托管的 django 网站上使用“电子邮件 - 密码”组合而不是“用户名 - 密码”登录
我使用了this tutorial,它在我的计算机上运行良好(包括迁移),但是当我尝试迁移我的在线安装时,我收到一条错误消息:
"django.db.migrations.exceptions.NodeNotFoundError: Migration account.0001_initial dependencies reference nonexistent parent node ('auth', '0010_alter_group_name_max_length')"
迁移文件如下所示:
class Migration(migrations.Migration):
initial = True
dependencies = [
('auth', '0010_alter_group_name_max_length'),
]
operations = [
migrations.CreateModel(
name='User',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')),
('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
('email', models.EmailField(max_length=254, unique=True, verbose_name='email address')),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
],
options={
'verbose_name': 'user',
'verbose_name_plural': 'users',
'abstract': False,
},
managers=[
('objects', account.models.UserManager()),
],
),
]
我的ÌNSTALLED_APPS来自settings.py:
# Application definition
INSTALLED_APPS = [
#Base apps
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
#3rd party
'rest_framework',
'rest_framework.authtoken',
#local apps
'account',
'company',
'api',
]
如您所见,我的文件中有这一行,这使得我的迁移需要在 auth 文件夹中进行迁移(我认为这是 django 框架的 auth 文件夹
('auth','0010_alter_group_name_max_length'),
在网上我发现它是django project git中的一个现有文件
可能是因为我必须安装 django-heroku pip 包以使该项目与 Heroku 服务器兼容?
我不知道如何使这个项目发挥作用。我尝试删除迁移文件中的依赖项,但在这种情况下出现另一个错误:
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/fields/related.py", line 604, in resolve_related_fields
raise ValueError('Related model %r cannot be resolved' % self.remote_field.model)
ValueError: Related model 'auth.Group' cannot be resolved
感谢您的帮助
【问题讨论】:
-
欢迎来到 Stack Overflow。请edit您的问题并向我们展示您的
settings.py的INSTALLED_APPS部分。 -
您好,谢谢,已编辑完毕
-
该迁移看起来将包含在尚未发布的 Django 2.2 中(尽管它是 available in 2.2a1, 2.2b1, and 2.2rc1)。您使用的是 Django 2.2。在您的本地计算机上预发布?为什么你的
requirements.txt或Pipfile和Pipfile.lock没有反映出来? -
如果你再次edit你的问题并添加你的依赖文件(
requirements.txt或Pipfile)我们可以和你一起看看。 -
好像我有 Django==2.2.dev20190101154022
标签: python django heroku django-rest-framework heroku-postgres