Opened 13 years ago

Closed 13 years ago

#15985 closed New feature (duplicate)

manage.py syncdb without loading initial data

Reported by: michaeljean Owned by: nobody
Component: Core (Management commands) Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

Example usage:
[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.

Change History (1)

comment:1 by Aymeric Augustin, 13 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #15926.

Note: See TracTickets for help on using tickets.
Back to Top