summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2015-12-14 01:20:10 -0500
committerSimon Charette <charette.s@gmail.com>2015-12-15 12:22:59 -0500
commitc4e372aaf467ae41315cfe56a718a80469fc5318 (patch)
tree2c88abbb33c536c4a5f94aecf15756265783d7ce
parentb7fdd60d85ee94df444369be1b2c778cda44a0c2 (diff)
Fixed #25852 -- Made sure AlterModelManager forces a reload of its model state.
Thanks to Geoffrey Sechter and the Django NYC group for the report and Markus for the review.
-rw-r--r--django/db/migrations/operations/models.py1
-rw-r--r--docs/releases/1.8.8.txt3
-rw-r--r--docs/releases/1.9.1.txt3
-rw-r--r--tests/migrations/test_operations.py5
4 files changed, 12 insertions, 0 deletions
diff --git a/django/db/migrations/operations/models.py b/django/db/migrations/operations/models.py
index 2855107e0e..eabffa1b7d 100644
--- a/django/db/migrations/operations/models.py
+++ b/django/db/migrations/operations/models.py
@@ -590,6 +590,7 @@ class AlterModelManagers(Operation):
def state_forwards(self, app_label, state):
model_state = state.models[app_label, self.name_lower]
model_state.managers = list(self.managers)
+ state.reload_model(app_label, self.name_lower)
def database_forwards(self, app_label, schema_editor, from_state, to_state):
pass
diff --git a/docs/releases/1.8.8.txt b/docs/releases/1.8.8.txt
index 5dca5bccdb..6ba76d71cb 100644
--- a/docs/releases/1.8.8.txt
+++ b/docs/releases/1.8.8.txt
@@ -34,3 +34,6 @@ Bugfixes
* Fixed missing ``varchar/text_pattern_ops`` index on ``CharField`` and
``TextField`` respectively when using ``AlterField`` on PostgreSQL
(:ticket:`25412`).
+
+* Fixed a state bug when using an ``AlterModelManagers`` operation
+ (:ticket:`25852`).
diff --git a/docs/releases/1.9.1.txt b/docs/releases/1.9.1.txt
index 520c2b3c31..25acbd540b 100644
--- a/docs/releases/1.9.1.txt
+++ b/docs/releases/1.9.1.txt
@@ -40,3 +40,6 @@ Bugfixes
* Fixed evaluation of zero-length slices of ``QuerySet.values()``
(:ticket:`25894`).
+
+* Fixed a state bug when using an ``AlterModelManagers`` operation
+ (:ticket:`25852`).
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py
index 51d4d5bbbb..b624a73392 100644
--- a/tests/migrations/test_operations.py
+++ b/tests/migrations/test_operations.py
@@ -1393,6 +1393,11 @@ class OperationTests(OperationTestBase):
self.assertEqual(managers[2][0], "food_mgr_kwargs")
self.assertIsInstance(managers[2][1], FoodManager)
self.assertEqual(managers[2][1].args, ("x", "y", 3, 4))
+ rendered_state = new_state.apps
+ model = rendered_state.get_model('test_almoma', 'pony')
+ self.assertIsInstance(model.food_qs, models.Manager)
+ self.assertIsInstance(model.food_mgr, FoodManager)
+ self.assertIsInstance(model.food_mgr_kwargs, FoodManager)
def test_alter_model_managers_emptying(self):
"""