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)
4

1 回答 1

3

不要使用initial_data带有 South 的灯具。重命名initial_data.json为其他名称并在数据迁移中加载此夹具

def forwards(self, orm):
    from django.core.management import call_command
    call_command("loaddata", "my_fixture.json")
于 2015-01-22T09:16:12.170 回答