【问题标题】:How to show what fixtures are installed when I run migrate command in Django?当我在 Django 中运行迁移命令时,如何显示安装了哪些固定装置?
【发布时间】:2015-03-20 23:56:31
【问题描述】:

我正在使用 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)

【问题讨论】:

    标签: python django django-south django-1.6 django-fixtures


    【解决方案1】:

    不要将 initial_data 灯具与 South 一起使用。将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")
    

    【讨论】:

    • 我按照你的建议做了,但是问题仍然存在
    猜你喜欢
    • 2011-04-29
    • 2020-10-05
    • 2016-05-03
    • 1970-01-01
    • 2015-02-10
    • 2012-11-29
    • 1970-01-01
    • 1970-01-01
    • 2016-07-05
    相关资源
    最近更新 更多