1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #33515 -- Prevented recreation of migration for ManyToManyField to lowercased swappable setting.

Thanks Chris Lee for the report.

Regression in 4328970780.

Refs #23916.
This commit is contained in:
Mariusz Felisiak
2022-02-16 21:09:24 +01:00
committed by GitHub
parent 35c2474f16
commit 1e2e1be02b
4 changed files with 45 additions and 14 deletions

View File

@@ -3279,6 +3279,31 @@ class AutodetectorTests(TestCase):
[("__setting__", "AUTH_USER_MODEL")],
)
@override_settings(AUTH_USER_MODEL="thirdapp.CustomUser")
def test_swappable_many_to_many_model_case(self):
document_lowercase = ModelState(
"testapp",
"Document",
[
("id", models.AutoField(primary_key=True)),
("owners", models.ManyToManyField(settings.AUTH_USER_MODEL.lower())),
],
)
document = ModelState(
"testapp",
"Document",
[
("id", models.AutoField(primary_key=True)),
("owners", models.ManyToManyField(settings.AUTH_USER_MODEL)),
],
)
with isolate_lru_cache(apps.get_swappable_settings_name):
changes = self.get_changes(
[self.custom_user, document_lowercase],
[self.custom_user, document],
)
self.assertEqual(len(changes), 0)
def test_swappable_changed(self):
with isolate_lru_cache(apps.get_swappable_settings_name):
before = self.make_project_state([self.custom_user, self.author_with_user])