ValueError: Cannot alter field main_app.Event.participants into main_app.Event.participants - they are not compatible types (you cannot alter to or from M2M fields, or add or remove through= on M2M fields) code example

Example: 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'),
),