更新时间:2021-08-21 23:36:29
我偶然发现了这个,虽然我不太关心我的数据,但我仍然不想删除整个数据库.因此,我打开了迁移文件并将 AlterField()
命令更改为运行良好的 RemoveField()
和 AddField()
命令.我丢失了我在特定领域的数据,但没有别的.
I stumbled upon this and although I didn't care about my data much, I still didn't want to delete the whole DB. So I opened the migration file and changed the AlterField()
command to a RemoveField()
and an AddField()
command that worked well. I lost my data on the specific field, but nothing else.
即
migrations.AlterField(
model_name='player',
name='teams',
field=models.ManyToManyField(related_name='players', through='players.TeamPlayer', to='players.Team'),
),
到
migrations.RemoveField(
model_name='player',
name='teams',
),
migrations.AddField(
model_name='player',
name='teams',
field=models.ManyToManyField(related_name='players', through='players.TeamPlayer', to='players.Team'),
),