#NEWLINE# def handle_noargs( self , migrate_all = False , **options ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# from django.utils.importlib import import_module #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# for app_name in settings . INSTALLED_APPS : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# import_module ( '.management' , app_name ) #NEWLINE# #UNINDENT# except ImportError as exc : #NEWLINE# #INDENT# msg = exc . args [ 0 ] #NEWLINE# if ( ( not msg . startswith ( 'No module named' ) ) or ( 'management' not in msg ) ) : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# apps_needing_sync = [ ] #NEWLINE# apps_migrated = [ ] #NEWLINE# for app in models . get_apps ( ) : #NEWLINE# #INDENT# app_label = get_app_label ( app ) #NEWLINE# if migrate_all : #NEWLINE# #INDENT# apps_needing_sync . append ( app_label ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# migrations = migration . Migrations ( app_label ) #NEWLINE# #UNINDENT# except NoMigrations : #NEWLINE# #INDENT# apps_needing_sync . append ( app_label ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# apps_migrated . append ( app_label ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# verbosity = int ( options . get ( 'verbosity' , 0 ) ) #NEWLINE# if verbosity : #NEWLINE# #INDENT# print ( 'Syncing...' ) #NEWLINE# #UNINDENT# ( old_installed , settings . INSTALLED_APPS ) = ( settings . INSTALLED_APPS , apps_needing_sync ) #NEWLINE# ( old_app_store , cache . app_store ) = ( cache . app_store , SortedDict ( [ ( k , v ) for ( k , v ) in cache . app_store . items ( ) if ( get_app_label ( k ) in apps_needing_sync ) ] ) ) #NEWLINE# for db in dbs . values ( ) : #NEWLINE# #INDENT# db . connection_init ( ) #NEWLINE# #UNINDENT# syncdb . Command ( ) . execute ( ** options ) #NEWLINE# settings . INSTALLED_APPS = old_installed #NEWLINE# cache . app_store = old_app_store #NEWLINE# if options . get ( 'migrate' , True ) : #NEWLINE# #INDENT# if exc : #NEWLINE# #INDENT# print ( 'Migrating...' ) #NEWLINE# #UNINDENT# options [ 'no_initial_data' ] = ( not options . get ( 'load_initial_data' , True ) ) #NEWLINE# management . call_command ( 'migrate' , ** options ) #NEWLINE# #UNINDENT# if verbosity : #NEWLINE# #INDENT# print ( ( '\nSynced:\n > %s' % '\n > ' . join ( apps_needing_sync ) ) ) #NEWLINE# #UNINDENT# if options . get ( 'migrate' , True ) : #NEWLINE# #INDENT# if verbosity : #NEWLINE# #INDENT# print ( ( '\nMigrated:\n - %s' % '\n - ' . join ( apps_migrated ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if verbosity : #NEWLINE# #INDENT# print ( ( '\nNot synced (use migrations):\n - %s' % '\n - ' . join ( apps_migrated ) ) ) #NEWLINE# print ( '(use ./manage.py migrate to migrate these)' )