Revert "[1.7.x] Fixed #22331 -- Fixed migrations ProjectState to ignore unmanaged models."
This reverts commit bf69375c4d
.
This commit is contained in:
parent
bf69375c4d
commit
d84beb3d91
|
@ -58,7 +58,6 @@ class ProjectState(object):
|
||||||
"Takes in an Apps and returns a ProjectState matching it"
|
"Takes in an Apps and returns a ProjectState matching it"
|
||||||
app_models = {}
|
app_models = {}
|
||||||
for model in apps.get_models():
|
for model in apps.get_models():
|
||||||
if model._meta.managed:
|
|
||||||
model_state = ModelState.from_model(model)
|
model_state = ModelState.from_model(model)
|
||||||
app_models[(model_state.app_label, model_state.name.lower())] = model_state
|
app_models[(model_state.app_label, model_state.name.lower())] = model_state
|
||||||
return cls(app_models)
|
return cls(app_models)
|
||||||
|
|
|
@ -52,22 +52,11 @@ class StateTests(TestCase):
|
||||||
verbose_name = "tome"
|
verbose_name = "tome"
|
||||||
db_table = "test_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)
|
project_state = ProjectState.from_apps(new_apps)
|
||||||
author_state = project_state.models['migrations', 'author']
|
author_state = project_state.models['migrations', 'author']
|
||||||
author_proxy_state = project_state.models['migrations', 'authorproxy']
|
author_proxy_state = project_state.models['migrations', 'authorproxy']
|
||||||
sub_author_state = project_state.models['migrations', 'subauthor']
|
sub_author_state = project_state.models['migrations', 'subauthor']
|
||||||
book_state = project_state.models['migrations', 'book']
|
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.app_label, "migrations")
|
||||||
self.assertEqual(author_state.name, "Author")
|
self.assertEqual(author_state.name, "Author")
|
||||||
|
|
Loading…
Reference in New Issue