Code

Opened 3 years ago

Closed 3 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:

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.

Attachments (0)

Change History (1)

comment:1 Changed 3 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #15926.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.