summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-03-17 20:48:30 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-03-18 00:03:58 +0100
commit20a91cce04c72bc8c64a1c43b7398edac7b709cc (patch)
treed505ae2def12275bbec1610bd1c50850467abf72 /django
parent68905695b897e62b0c18d9edd87171a0eae4e67e (diff)
Fixed #17037 -- Added a --all option to diffsettings.
Diffstat (limited to 'django')
-rw-r--r--django/core/management/commands/diffsettings.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/django/core/management/commands/diffsettings.py b/django/core/management/commands/diffsettings.py
index aa7395e5ee..9e70e9ad8f 100644
--- a/django/core/management/commands/diffsettings.py
+++ b/django/core/management/commands/diffsettings.py
@@ -1,14 +1,22 @@
+from optparse import make_option
+
from django.core.management.base import NoArgsCommand
def module_to_dict(module, omittable=lambda k: k.startswith('_')):
- "Converts a module namespace to a Python dictionary. Used by get_settings_diff."
- return dict([(k, repr(v)) for k, v in module.__dict__.items() if not omittable(k)])
+ """Converts a module namespace to a Python dictionary."""
+ return dict((k, repr(v)) for k, v in module.__dict__.items() if not omittable(k))
class Command(NoArgsCommand):
help = """Displays differences between the current settings.py and Django's
default settings. Settings that don't appear in the defaults are
followed by "###"."""
+ option_list = NoArgsCommand.option_list + (
+ make_option('--all', action='store_true', dest='all', default=False,
+ help='Display all settings, regardless of their value. '
+ 'Default values are prefixed by "###".'),
+ )
+
requires_model_validation = False
def handle_noargs(self, **options):
@@ -22,9 +30,11 @@ class Command(NoArgsCommand):
default_settings = module_to_dict(global_settings)
output = []
- for key in sorted(user_settings.keys()):
+ for key in sorted(user_settings):
if key not in default_settings:
output.append("%s = %s ###" % (key, user_settings[key]))
elif user_settings[key] != default_settings[key]:
output.append("%s = %s" % (key, user_settings[key]))
+ elif options['all']:
+ output.append("### %s = %s" % (key, user_settings[key]))
return '\n'.join(output)