manage.py syncdb without loading initial data
|Reported by:||michaeljean||Owned by:||nobody|
|Component:||Core (Management commands)||Version:||1.3|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I needed a way to rebuild the database structure without loading the initial data in order to make a custom subset of data. Basically what was needed was the same functionality as 'manage.py syncdb' except for the last step to load the initial data.
To do this, the django file django\core\management\syncdb.py was examined and it was observed that omitting the loading of initial data required minimal changes to the existing file.
The file django\core\management\commands\syncdb.py was copied and renamed django\core\management\commands\initializedb.py. Then the last 2 lines were deleted to disable the loading of the intial data:
from django.core.management import call_command
call_command('loaddata', 'initial_data', verbosity=verbosity, database=db)
The new file initialize.py enables the use of the command 'manage.py initializedb' using the same command line options as syncdb.
[root@oasdev os_so]# python manage.py initializedb --database='oas_datamart_test_data'
Handy for some things, violates DRY, but it works and I am am willing to contribute it.