﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33515	ManyToManyField to lowercased swappable setting causes generating infinite migrations.	Chris Lee	Mariusz Felisiak	"If I create a custom user model that extends `AbstractUser` and then try to add a `ManyToManyField` that references this custom User model, django keeps making the same `AlterField` migration over and over again unnecessarily. I've attached a Git repository that I used to reproduce this issue with very simple code. You can see the two erroneous migrations after the initial migration. If I use the built in user, there is no issue. It seems to appear once I extend `AbstractUser`.

Git repository: https://github.com/SentientClee/django-bug-reproduction

Here is the `accounts` app `model.py` code.
{{{#!python
from django.conf import settings
from django.contrib.auth.models import AbstractUser
from django.db import models


class User(AbstractUser):
    pass


class Test(models.Model):
    members = models.ManyToManyField(settings.AUTH_USER_MODEL)
}}}

Here is one of the erroneous migrations. Notice it depends on `0002_alter_test_members` which is an erroneous migrations file that looks just like this one.
{{{#!python
# Generated by Django 4.0.2 on 2022-02-15 01:33

from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('accounts', '0002_alter_test_members'),
    ]

    operations = [
        migrations.AlterField(
            model_name='test',
            name='members',
            field=models.ManyToManyField(to=settings.AUTH_USER_MODEL),
        ),
    ]
}}}"	Bug	closed	Migrations	4.0	Release blocker	fixed	M2M migration user manytomany	Simon Charette David Wobrock	Accepted	1	0	0	0	0	0
