diff --git a/django/db/migrations/state.py b/django/db/migrations/state.py index 01019ff980..ab2bd8e6d8 100644 --- a/django/db/migrations/state.py +++ b/django/db/migrations/state.py @@ -58,9 +58,8 @@ class ProjectState(object): "Takes in an Apps and returns a ProjectState matching it" app_models = {} for model in apps.get_models(): - if model._meta.managed: - model_state = ModelState.from_model(model) - app_models[(model_state.app_label, model_state.name.lower())] = model_state + model_state = ModelState.from_model(model) + app_models[(model_state.app_label, model_state.name.lower())] = model_state return cls(app_models) def __eq__(self, other): diff --git a/tests/migrations/test_state.py b/tests/migrations/test_state.py index 80ae8922bf..10f5e7d9ab 100644 --- a/tests/migrations/test_state.py +++ b/tests/migrations/test_state.py @@ -52,22 +52,11 @@ class StateTests(TestCase): verbose_name = "tome" db_table = "test_tome" - class Unmanaged(models.Model): - title = models.CharField(max_length=1000) - - class Meta: - app_label = "migrations" - apps = new_apps - managed = False - project_state = ProjectState.from_apps(new_apps) author_state = project_state.models['migrations', 'author'] author_proxy_state = project_state.models['migrations', 'authorproxy'] sub_author_state = project_state.models['migrations', 'subauthor'] book_state = project_state.models['migrations', 'book'] - # unmanaged models should not appear in migrations - with self.assertRaises(KeyError): - project_state.models['migrations', 'unmanaged'] self.assertEqual(author_state.app_label, "migrations") self.assertEqual(author_state.name, "Author")