Fixed #29755 -- Made migrations detect changes to Meta.default_related_name.
This commit is contained in:
parent
e7a0a5c8b2
commit
a4495f4b98
|
@ -638,6 +638,7 @@ class AlterModelOptions(ModelOptionOperation):
|
||||||
ALTER_OPTION_KEYS = [
|
ALTER_OPTION_KEYS = [
|
||||||
"base_manager_name",
|
"base_manager_name",
|
||||||
"default_manager_name",
|
"default_manager_name",
|
||||||
|
"default_related_name",
|
||||||
"get_latest_by",
|
"get_latest_by",
|
||||||
"managed",
|
"managed",
|
||||||
"ordering",
|
"ordering",
|
||||||
|
|
|
@ -14,3 +14,6 @@ Bugfixes
|
||||||
|
|
||||||
* Fixed a regression where files starting with a tilde or underscore weren't
|
* Fixed a regression where files starting with a tilde or underscore weren't
|
||||||
ignored by the migrations loader (:ticket:`29749`).
|
ignored by the migrations loader (:ticket:`29749`).
|
||||||
|
|
||||||
|
* Made migrations detect changes to ``Meta.default_related_name``
|
||||||
|
(:ticket:`29755`).
|
||||||
|
|
|
@ -2104,6 +2104,25 @@ class AutodetectorTests(TestCase):
|
||||||
self.assertOperationAttributes(changes, 'thirdapp', 0, 0, name="CustomUser")
|
self.assertOperationAttributes(changes, 'thirdapp', 0, 0, name="CustomUser")
|
||||||
self.assertOperationAttributes(changes, 'thirdapp', 0, 1, name="Aardvark")
|
self.assertOperationAttributes(changes, 'thirdapp', 0, 1, name="Aardvark")
|
||||||
|
|
||||||
|
def test_default_related_name_option(self):
|
||||||
|
model_state = ModelState('app', 'model', [
|
||||||
|
('id', models.AutoField(primary_key=True)),
|
||||||
|
], options={'default_related_name': 'related_name'})
|
||||||
|
changes = self.get_changes([], [model_state])
|
||||||
|
self.assertNumberMigrations(changes, 'app', 1)
|
||||||
|
self.assertOperationTypes(changes, 'app', 0, ['CreateModel'])
|
||||||
|
self.assertOperationAttributes(
|
||||||
|
changes, 'app', 0, 0, name='model',
|
||||||
|
options={'default_related_name': 'related_name'},
|
||||||
|
)
|
||||||
|
altered_model_state = ModelState('app', 'Model', [
|
||||||
|
('id', models.AutoField(primary_key=True)),
|
||||||
|
])
|
||||||
|
changes = self.get_changes([model_state], [altered_model_state])
|
||||||
|
self.assertNumberMigrations(changes, 'app', 1)
|
||||||
|
self.assertOperationTypes(changes, 'app', 0, ['AlterModelOptions'])
|
||||||
|
self.assertOperationAttributes(changes, 'app', 0, 0, name='model', options={})
|
||||||
|
|
||||||
@override_settings(AUTH_USER_MODEL="thirdapp.CustomUser")
|
@override_settings(AUTH_USER_MODEL="thirdapp.CustomUser")
|
||||||
def test_swappable_first_setting(self):
|
def test_swappable_first_setting(self):
|
||||||
"""Swappable models get their CreateModel first."""
|
"""Swappable models get their CreateModel first."""
|
||||||
|
|
Loading…
Reference in New Issue