@@ -78,18 +78,21 @@ def handle(self, *args, **options):
7878 args = [script_file ]
7979 options ['callable_object' ] = callable_object
8080
81- # If there is no BASE_DIR in Django settings, assume that
82- # the current working directory is the parent directory of
83- # the directory the settings module is in.
84-
85- if hasattr (settings , 'BASE_DIR' ):
86- options ['working_directory' ] = settings .BASE_DIR
87- else :
88- settings_module_path = os .environ ['DJANGO_SETTINGS_MODULE' ]
89- root_module_path = settings_module_path .split ('.' )[0 ]
90- root_module = sys .modules [root_module_path ]
91- parent = os .path .dirname (os .path .dirname (root_module .__file__ ))
92- options ['working_directory' ] = parent
81+ # If there is no BASE_DIR in Django settings, assume that the
82+ # current working directory is the parent directory of the
83+ # directory the settings module is in. Either way, allow the
84+ # --working-directory option to override it to deal with where
85+ # meaning of BASE_DIR in the Django settings was changed.
86+
87+ if options .get ('working_directory' ) is None :
88+ if hasattr (settings , 'BASE_DIR' ):
89+ options ['working_directory' ] = settings .BASE_DIR
90+ else :
91+ settings_module_path = os .environ ['DJANGO_SETTINGS_MODULE' ]
92+ root_module_path = settings_module_path .split ('.' )[0 ]
93+ root_module = sys .modules [root_module_path ]
94+ parent = os .path .dirname (os .path .dirname (root_module .__file__ ))
95+ options ['working_directory' ] = parent
9396
9497 url_aliases = options .setdefault ('url_aliases' ) or []
9598
0 commit comments