diff options
| author | Markus Holtermann <info@markusholtermann.eu> | 2013-09-01 17:42:43 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-09-06 09:51:58 -0400 |
| commit | bd8e1a354cb1fde5e5411e3c729a0d179f4eb37b (patch) | |
| tree | 218c93dfc5f9c7151bb690e2598d1398b84ef896 /django | |
| parent | 8625c7aab3760d16572792fea23a95e572e28ead (diff) | |
Fixed #20977 -- Fixed writing migrations to disk on Python 3
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/management/commands/makemigrations.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/django/core/management/commands/makemigrations.py b/django/core/management/commands/makemigrations.py index d802e2924a..e897bbdb9d 100644 --- a/django/core/management/commands/makemigrations.py +++ b/django/core/management/commands/makemigrations.py @@ -52,7 +52,7 @@ class Command(BaseCommand): changes = autodetector.changes(graph=loader.graph, trim_to_apps=app_labels or None) # No changes? Tell them. - if not changes: + if not changes and self.verbosity >= 1: if len(app_labels) == 1: self.stdout.write("No changes detected in app '%s'" % app_labels.pop()) elif len(app_labels) > 1: @@ -63,13 +63,15 @@ class Command(BaseCommand): directory_created = {} for app_label, migrations in changes.items(): - self.stdout.write(self.style.MIGRATE_HEADING("Migrations for '%s':" % app_label) + "\n") + if self.verbosity >= 1: + self.stdout.write(self.style.MIGRATE_HEADING("Migrations for '%s':" % app_label) + "\n") for migration in migrations: # Describe the migration writer = MigrationWriter(migration) - self.stdout.write(" %s:\n" % (self.style.MIGRATE_LABEL(writer.filename),)) - for operation in migration.operations: - self.stdout.write(" - %s\n" % operation.describe()) + if self.verbosity >= 1: + self.stdout.write(" %s:\n" % (self.style.MIGRATE_LABEL(writer.filename),)) + for operation in migration.operations: + self.stdout.write(" - %s\n" % operation.describe()) # Write it migrations_directory = os.path.dirname(writer.path) if not directory_created.get(app_label, False): @@ -80,5 +82,5 @@ class Command(BaseCommand): open(init_path, "w").close() # We just do this once per app directory_created[app_label] = True - with open(writer.path, "w") as fh: + with open(writer.path, "wb") as fh: fh.write(writer.as_string()) |
