首页 文章

如何在Django中运行migrate命令时显示安装的灯具?

提问于
浏览
0

我正在使用Django 1.6和South进行迁移 . 我有一个夹具 initial_data.json . 当我运行 ./manage.py syncdb 我得到

Installed 48 object(s) from 1 fixture(s)

但是,当我运行 ./manage.py migrate 时,我得到了

Installed 96 object(s) from 2 fixture(s)

看起来信息翻倍 . 如何在migrate命令中查看完全安装的灯具?这个问题对我来说很重要,因为我在项目中的某些其他地方加载了夹具数据,这可能就是原因 .

upd 我按照建议将数据迁移到了 migrate 上的加载装置,但是有两次迁移而不是一次迁移的问题仍然存在:

./manage.py migrate
Running migrations for hello:
 - Migrating forwards to 0007_migration_fixture.
 > hello:0007_migration_fixture
 - Migration 'hello:0007_migration_fixture' is marked for no-dry-run.
Installed 102 object(s) from 2 fixture(s)
 - Loading initial data for hello.
Installed 0 object(s) from 0 fixture(s)

1 回答

  • 3

    不要在南方使用 initial_data 灯具 . 将 initial_data.json 重命名为其他名称和load this fixture in the data migration

    def forwards(self, orm):
        from django.core.management import call_command
        call_command("loaddata", "my_fixture.json")
    

相关问题