Ticket #17037: django_manage_py_diffsettings_all_v2.diff

File django_manage_py_diffsettings_all_v2.diff, 1.3 KB (added by msabramo, 4 years ago)

Patch to add --all option to diffsettings management command

  • django/core/management/commands/diffsettings.py

     
     1from optparse import make_option
     2
    13from django.core.management.base import NoArgsCommand
    24
    35def module_to_dict(module, omittable=lambda k: k.startswith('_')):
     
    911    default settings. Settings that don't appear in the defaults are
    1012    followed by "###"."""
    1113
     14    option_list = NoArgsCommand.option_list + (
     15        make_option('--all', action='store_true', dest='all',
     16            default=False, help='Display all settings; not just ones '
     17                'that differ from Django defaults. Settings that equal '
     18                'the defaults are prefixed with "# (Default)".'),
     19    )
     20
    1221    requires_model_validation = False
    1322
    1423    def handle_noargs(self, **options):
     
    2938                output.append("%s = %s  ###" % (key, user_settings[key]))
    3039            elif user_settings[key] != default_settings[key]:
    3140                output.append("%s = %s" % (key, user_settings[key]))
     41            elif options.get('all', False):
     42                output.append("# (Default) %s = %s" % (key, user_settings[key]))
    3243        return '\n'.join(output)
Back to Top