Search code examples
pythondjangodjango-southdjango-1.6django-fixtures

How to show what fixtures are installed when I run migrate command in Django?


I am using Django 1.6 and South for migrations. I have one single fixture initial_data.json. When i run ./manage.py syncdb I get

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

However when I run ./manage.py migrate I get

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

Looks like information doubles. How to watch what fixtures are installed exactly on migrate command? This issue is important for me because I have data duplication on fixtures load in some other place in the project and this could be the reason.

upd I followed the suggestion to creade data migration to load fixtures on migrate but the question with two migrations instead of one remained:

./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)

Solution

  • Do not use initial_data fixtures with South. Rename initial_data.json to some other name and load this fixture in the data migration:

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