I have a bootstrap
script that performs syncdb
and migrate
:
import settings
from django.core.management import setup_environ, call_command
setup_environ(settings) # Setting up the env settings
call_command('syncdb', migrate=True, interactive=False) # Sync the database
Pre-Requisites:
django-south
for migrations.Process happening:
initial_data
fixture contains data for a model that is created by migrations.syncdb
is executed it creates all the tables except for those apps where migrations exists.syncdb
it tries to load initial_data
and raises error of db not found because the table for app with migrations were not created by syncdb. [ Problem ]migration
it automatically loads initial_data
successfully this time.Problem:
error
, when it tries to load fixture for the table that is not yet created ?initial_data
only after performing the migration
?You could disable loading initial data when syncdb:
call_command('syncdb', load_initial_data=False, interactive=False)
call_command('migrate', interactive=False)
From the source code of syncdb.py:
# Stealth option -- 'load_initial_data' is used by the testing setup
# process to disable initial fixture loading.
load_initial_data = options.get('load_initial_data', True)