1
from django.core.management.base import NoArgsCommand
3
def module_to_dict(module, omittable=lambda k: k.startswith('_')):
4
"Converts a module namespace to a Python dictionary. Used by get_settings_diff."
5
return dict([(k, repr(v)) for k, v in module.__dict__.items() if not omittable(k)])
7
class Command(NoArgsCommand):
8
help = """Displays differences between the current settings.py and Django's
9
default settings. Settings that don't appear in the defaults are
12
requires_model_validation = False
14
def handle_noargs(self, **options):
15
# Inspired by Postfix's "postconf -n".
16
from django.conf import settings, global_settings
18
# Because settings are imported lazily, we need to explicitly load them.
19
settings._import_settings()
21
user_settings = module_to_dict(settings._target)
22
default_settings = module_to_dict(global_settings)
25
keys = user_settings.keys()
28
if key not in default_settings:
29
output.append("%s = %s ###" % (key, user_settings[key]))
30
elif user_settings[key] != default_settings[key]:
31
output.append("%s = %s" % (key, user_settings[key]))
32
print '\n'.join(output)