diff --git a/django/core/management/commands/makemigrations.py b/django/core/management/commands/makemigrations.py index 8938fb6309c..ec6b71f5a0a 100644 --- a/django/core/management/commands/makemigrations.py +++ b/django/core/management/commands/makemigrations.py @@ -254,12 +254,7 @@ class Command(BaseCommand): if self.verbosity >= 1: # Display a relative path if it's below the current working # directory, or an absolute path otherwise. - try: - migration_string = os.path.relpath(writer.path) - except ValueError: - migration_string = writer.path - if migration_string.startswith(".."): - migration_string = writer.path + migration_string = self.get_relative_path(writer.path) self.log(" %s\n" % self.style.MIGRATE_LABEL(migration_string)) for operation in migration.operations: self.log(" - %s" % operation.describe()) @@ -291,6 +286,16 @@ class Command(BaseCommand): self.log(writer.as_string()) run_formatters(self.written_files) + @staticmethod + def get_relative_path(path): + try: + migration_string = os.path.relpath(path) + except ValueError: + migration_string = path + if migration_string.startswith(".."): + migration_string = path + return migration_string + def handle_merge(self, loader, conflicts): """ Handles merging together conflicted migrations interactively,