django - 手动初始迁移获取原始sql脚本

时间:2015-11-09 18:18:43

标签: django

最初设置Django时,运行以下命令 -

manage.py migrate

然后输出以下内容(作为示例):

Operations to perform:
  Synchronize unmigrated apps: staticfiles, rest_framework, rest_framework_swagger, messages
  Apply all migrations: admin, contenttypes, auth, sessions
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  Rendering model states... DONE
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying sessions.0001_initial... OK

有没有办法获得它正在加载的原始SQL?

1 个答案:

答案 0 :(得分:3)

是运行:manage.py sqlmigrate