diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py
index 85bf324..0e69364 100644
a
|
b
|
def get_commands():
|
102 | 102 | except (AttributeError, EnvironmentError, ImportError): |
103 | 103 | apps = [] |
104 | 104 | |
105 | | # Find the project directory |
106 | | try: |
107 | | from django.conf import settings |
108 | | module = import_module(settings.SETTINGS_MODULE) |
109 | | project_directory = setup_environ(module, settings.SETTINGS_MODULE) |
110 | | except (AttributeError, EnvironmentError, ImportError, KeyError): |
111 | | project_directory = None |
112 | | |
113 | 105 | # Find and load the management module for each installed app. |
114 | 106 | for app_name in apps: |
115 | 107 | try: |
… |
… |
def get_commands():
|
119 | 111 | except ImportError: |
120 | 112 | pass # No management module - ignore this app |
121 | 113 | |
| 114 | project_directory = get_project_directory() |
122 | 115 | if project_directory: |
123 | | # Remove the "startproject" command from self.commands, because |
124 | | # that's a django-admin.py command, not a manage.py command. |
125 | | del _commands['startproject'] |
| 116 | _commands = revise_commands_for_manage_py(_commands, project_directory) |
| 117 | |
| 118 | return _commands |
| 119 | |
| 120 | def revise_commands_for_manage_py(_commands, project_directory): |
| 121 | # Remove the "startproject" command, because that's a |
| 122 | # django-admin.py command, not a manage.py command. |
| 123 | del _commands['startproject'] |
126 | 124 | |
127 | | # Override the startapp command so that it always uses the |
128 | | # project_directory, not the current working directory |
129 | | # (which is default). |
130 | | from django.core.management.commands.startapp import ProjectCommand |
131 | | _commands['startapp'] = ProjectCommand(project_directory) |
| 125 | # Override the startapp command so that it always uses the |
| 126 | # project_directory, not the current working directory |
| 127 | # (which is default). |
| 128 | from django.core.management.commands.startapp import ProjectCommand |
| 129 | _commands['startapp'] = ProjectCommand(project_directory) |
132 | 130 | |
133 | 131 | return _commands |
134 | 132 | |
| 133 | def get_project_directory(): |
| 134 | """ |
| 135 | Find the project directory |
| 136 | """ |
| 137 | try: |
| 138 | from django.conf import settings |
| 139 | module = import_module(settings.SETTINGS_MODULE) |
| 140 | project_directory = setup_environ(module, settings.SETTINGS_MODULE) |
| 141 | except (AttributeError, EnvironmentError, ImportError, KeyError): |
| 142 | project_directory = None |
| 143 | |
| 144 | return project_directory |
| 145 | |
135 | 146 | def call_command(name, *args, **options): |
136 | 147 | """ |
137 | 148 | Calls the given command, with the given options and args/kwargs. |
… |
… |
class ManagementUtility(object):
|
240 | 251 | commands.sort() |
241 | 252 | for cmd in commands: |
242 | 253 | usage.append(' %s' % cmd) |
| 254 | project_directory = get_project_directory() |
| 255 | if project_directory and os.getenv('DJANGO_SETTINGS_MODULE'): |
| 256 | usage.append('\nNote that the "startproject" subcommand is disabled, ' + |
| 257 | 'because the DJANGO_SETTINGS_MODULE environment variable is set ' + |
| 258 | '(to %r).' % os.getenv('DJANGO_SETTINGS_MODULE')) |
243 | 259 | return '\n'.join(usage) |
244 | 260 | |
245 | 261 | def fetch_command(self, subcommand): |