我正在尝试让用户在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
的{{1}}:
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',
]
文件夹(我认为这是django框架的auth文件夹)中进行迁移
auth
在网络上,我发现它是django project git
中的现有文件。也许是由于必须安装('auth','0010_alter_group_name_max_length'),
pip程序包才能使该项目与heroku服务器兼容?
我不知道如何使该项目正常工作。我尝试删除迁移文件中的依赖项,但在这种情况下又遇到另一个错误:
django-heroku
感谢您的帮助
答案 0 :(得分:0)
正如Chris在评论中所注意到的那样,我在本地和在线上都有不同版本的Django,本地版本的Django是Django == 2.2.dev20190101154022,在线版本是Django == 2.1.7,其中有一个不同的迁移文件(在Django 2.1.7中为0009_alter_user_last_name_max_length
,在2.2.dev20190101154022中为0010_alter_group_name_max_length
)
答案 1 :(得分:0)