Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #19724 -- Output note when showing only core management commands

When listing available management commands, only core commands are
listed if settings have any error. This commit adds a note in this
case so errors are not totally silently skipped.
Thanks Peter Davis for the report.
  • Loading branch information...
commit a098bee1b9fa4df64f3fd72ff5cbae43bf27e539 1 parent 86c248a
@claudep claudep authored
Showing with 20 additions and 0 deletions.
  1. +9 −0 django/core/management/__init__.py
  2. +11 −0 tests/admin_scripts/tests.py
View
9 django/core/management/__init__.py
@@ -249,6 +249,15 @@ def main_help_text(self, commands_only=False):
usage.append(style.NOTICE("[%s]" % app))
for name in sorted(commands_dict[app]):
usage.append(" %s" % name)
+ # Output an extra note if settings are not properly configured
+ try:
+ from django.conf import settings
+ settings.INSTALLED_APPS
+ except ImproperlyConfigured as e:
+ usage.append(style.NOTICE(
+ "Note that only Django core commands are listed as settings "
+ "are not properly configured (error: %s)." % e))
+
return '\n'.join(usage)
def fetch_command(self, subcommand):
View
11 tests/admin_scripts/tests.py
@@ -1055,6 +1055,17 @@ def test_key_error(self):
self.assertNoOutput(out)
self.assertOutput(err, "KeyError: 'blah'")
+ def test_help(self):
+ """
+ Test listing available commands output note when only core commands are
+ available.
+ """
+ self.write_settings('settings.py', sdict={'MEDIA_URL': '"/no_ending_slash"'})
+ args = ['help']
+ out, err = self.run_manage(args)
+ self.assertOutput(out, 'only Django core commands are listed')
+ self.assertNoOutput(err)
+
class ManageValidate(AdminScriptTestCase):
def tearDown(self):
Please sign in to comment.
Something went wrong with that request. Please try again.