mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #25259 -- Added comments to header of generated migration files
This commit is contained in:
committed by
Markus Holtermann
parent
235caabacc
commit
e34226fc37
@@ -10,6 +10,7 @@ import re
|
||||
import types
|
||||
from importlib import import_module
|
||||
|
||||
from django import get_version
|
||||
from django.apps import apps
|
||||
from django.db import migrations, models
|
||||
from django.db.migrations.loader import MigrationLoader
|
||||
@@ -21,7 +22,7 @@ from django.utils.encoding import force_text
|
||||
from django.utils.functional import Promise
|
||||
from django.utils.inspect import get_func_args
|
||||
from django.utils.module_loading import module_dir
|
||||
from django.utils.timezone import utc
|
||||
from django.utils.timezone import now, utc
|
||||
from django.utils.version import get_docs_version
|
||||
|
||||
|
||||
@@ -211,6 +212,11 @@ class MigrationWriter(object):
|
||||
# If there's a replaces, make a string for it
|
||||
if self.migration.replaces:
|
||||
items['replaces_str'] = "\n replaces = %s\n" % self.serialize(self.migration.replaces)[0]
|
||||
# Hinting that goes into comment
|
||||
items.update(
|
||||
version=get_version(),
|
||||
timestamp=now().strftime("%Y-%m-%d %H:%M"),
|
||||
)
|
||||
|
||||
if self.migration.initial:
|
||||
items['initial_str'] = "\n initial = True\n"
|
||||
@@ -526,6 +532,7 @@ class MigrationWriter(object):
|
||||
|
||||
MIGRATION_TEMPLATE = """\
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django %(version)s on %(timestamp)s
|
||||
from __future__ import unicode_literals
|
||||
|
||||
%(imports)s
|
||||
|
||||
Reference in New Issue
Block a user