diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py index 0fd37ef5c9..469fd1199f 100644 --- a/django/db/migrations/autodetector.py +++ b/django/db/migrations/autodetector.py @@ -157,7 +157,7 @@ class MigrationAutodetector(object): # Alright, there's a dependency on the same app. for j, op2 in enumerate(ops): if self.check_dependency(op2, dep) and j > i: - ops = ops[:i] + ops[i+1:j+1] + [op] + ops[j+1:] + ops = ops[:i] + ops[i + 1:j + 1] + [op] + ops[j + 1:] found = True break if found: @@ -384,7 +384,7 @@ class MigrationAutodetector(object): name=name, field=field, ), - dependencies = [ + dependencies=[ (dep_app_label, dep_object_name, None, True), ] ) @@ -396,7 +396,7 @@ class MigrationAutodetector(object): name=model_name, unique_together=unique_together, ), - dependencies = [ + dependencies=[ (app_label, model_name, name, True) for name, field in sorted(related_fields.items()) ] @@ -408,7 +408,7 @@ class MigrationAutodetector(object): name=model_name, index_together=index_together, ), - dependencies = [ + dependencies=[ (app_label, model_name, name, True) for name, field in sorted(related_fields.items()) ] @@ -499,7 +499,7 @@ class MigrationAutodetector(object): operations.DeleteModel( name=model_state.name, ), - dependencies = list(set(dependencies)), + dependencies=list(set(dependencies)), ) def generate_added_fields(self): diff --git a/django/db/migrations/optimizer.py b/django/db/migrations/optimizer.py index 81060886a0..2f6ab6be4a 100644 --- a/django/db/migrations/optimizer.py +++ b/django/db/migrations/optimizer.py @@ -51,7 +51,7 @@ class MigrationOptimizer(object): for i, operation in enumerate(operations): # Compare it to each operation after it for j, other in enumerate(operations[i + 1:]): - result = self.reduce(operation, other, operations[i+1:i+j+1]) + result = self.reduce(operation, other, operations[i + 1:i + j + 1]) if result is not None: # Optimize! Add result, then remaining others, then return new_operations.extend(result)