mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Avoided creating temporary lists for obtaining the first item.
This commit is contained in:
committed by
Tim Graham
parent
0f905e4b44
commit
aadd3aeb2b
@@ -156,9 +156,9 @@ class MigrationLoader:
|
||||
if key[0] in self.migrated_apps:
|
||||
try:
|
||||
if key[1] == "__first__":
|
||||
return list(self.graph.root_nodes(key[0]))[0]
|
||||
return self.graph.root_nodes(key[0])[0]
|
||||
else: # "__latest__"
|
||||
return list(self.graph.leaf_nodes(key[0]))[0]
|
||||
return self.graph.leaf_nodes(key[0])[0]
|
||||
except IndexError:
|
||||
if self.ignore_no_migrations:
|
||||
return None
|
||||
|
||||
@@ -48,7 +48,7 @@ class MigrationQuestioner:
|
||||
elif hasattr(migrations_module, "__path__"):
|
||||
if len(migrations_module.__path__) > 1:
|
||||
return False
|
||||
filenames = os.listdir(list(migrations_module.__path__)[0])
|
||||
filenames = os.listdir(migrations_module.__path__[0])
|
||||
return not any(x.endswith(".py") for x in filenames if x != "__init__.py")
|
||||
|
||||
def ask_not_null_addition(self, field_name, model_name):
|
||||
|
||||
Reference in New Issue
Block a user