﻿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
33119	Change casing of a model's name referenced by ManyToManyField generates unnecessary migrations.	AliGhotbizadeh	nobody	"I have models like

{{{
#!python
class DataCenter(models.Model):
    title = models.CharField(max_length=100)

class Project(models.Model):
    datacenter = models.ForeignKey('DataCenter', on_delete=models.CASCADE)
}}}

Then I have decided to rename it into ""Datacenter"" so I was refactored my code and call the ""makemigrations"" command. But no migration file has created and it was obvious because model names are lowercased in the database schema.
after a while, I have added this model

{{{
#!python
class Package(models.Model):
   datacenters = models.ManyToManyField('Datacenter')
}}}

after creating that model every time I call the ""makemigrations"" command, the same alter migration has been created.

{{{
#!python
migrations.AlterField(
            model_name='package',
            name='datacenters',
            field=models.ManyToManyField(related_name='packages', to='operations.Datacenter',
                                         verbose_name='datacenters'),
),
}}}

after hours of debugging, I found that in the MigrationLoader's graph, the model name is ""DataCenter"" because no ""RenameModel"" migration is even created. then in the ""deconstruct"" of the M2M field unlike the ForiegnKey field, the ""to"" attribute is set from ""_meta.label"" instead of ""_meta.label_lower"".
and that causes a false change detection in ""MigrationAutodetector"" every time."	Bug	closed	Migrations	3.2	Normal	fixed	M2M,RenameModel,deconstruct		Unreviewed	0	0	0	0	0	0
