Answers for "you cannot alter to or from M2M fields, or add or remove through= on M2M fields)"

0

you cannot alter to or from M2M fields, or add or remove through= on M2M fields)

#convert migration file
migrations.AlterField(
    model_name='player',
    name='teams',
    field=models.ManyToManyField(related_name='players', through='players.TeamPlayer', to='players.Team'),
),
#to
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'),
),
Posted by: Guest on September-07-2020

Code answers related to "you cannot alter to or from M2M fields, or add or remove through= on M2M fields)"

Python Answers by Framework

Browse Popular Code Answers by Language