Opened 18 years ago

Closed 18 years ago

#1549 closed enhancement (fixed)

[patch] django-admin.py diffsettings: display differences between project settings and default settings

Reported by: pb@… Owned by: Adrian Holovaty
Component: Core (Management commands) Version: magic-removal
Severity: minor Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Per Adrian's encouragement (http://groups.google.com/group/django-developers/msg/069f6ed196c7c771), here's some code that does a diff-like operation between the current project's settings.py and Django's default settings.

Example usage: manage.py diffsettings (also works with django-admin.py)

This produces a clean, sorted, comment-free list of the settings that diverge from the defaults. Settings with no corresponding default values are followed by '###'; it seemed like a good idea to highlight "new" settings (including user-created ones), but I also wanted the output of this command to be usable as a settings file -- in theory, you could clean up your settings file by replacing it with the output of this command.

It's modeled after Postfix's "postconf -n", which is often used on the Postfix mailing for troubleshooting.

If this isn't deemed useful, no problem, but I wanted to contribute it just in case. Suggestions for a better command name than "diffsettings" are especially welcome.

Attachments (2)

diffsettings.patch (2.5 KB ) - added by pb@… 18 years ago.
patch to core/management.py
diffsettings2.patch (837 bytes ) - added by pb@… 18 years ago.
Python 2.3 compatible version

Download all attachments as: .zip

Change History (10)

by pb@…, 18 years ago

Attachment: diffsettings.patch added

patch to core/management.py

comment:1 by pb@…, 18 years ago

Version: magic-removal

(Set version to magic-removal)

comment:2 by pb@…, 18 years ago

Summary: [patch] Display differences between project settings and default settings[patch] django-admin.py diffsettings: display differences between project settings and default settings

(clarification)

comment:3 by Adrian Holovaty, 18 years ago

Thanks very much for this awesome patch!

comment:4 by Adrian Holovaty, 18 years ago

Resolution: fixed
Status: newclosed

(In [2671]) magic-removal: Fixed #1549 -- Added 'manage.py diffsettings', which displays differences between project settings and default settings. Thanks, Paul B.

comment:5 by Petar Marić <petar.maric@…>, 18 years ago

Resolution: fixed
Status: closedreopened

Doesn't work for me.

$ python manage.py diffsettings
Traceback (most recent call last):
  File "manage.py", line 11, in ?
    execute_manager(settings)
  File "/home/userX/django_src/django/core/management.py", line 1212, in execute_manager
    execute_from_command_line(action_mapping)
  File "/home/userX/django_src/django/core/management.py", line 1134, in execute_from_command_line
    action_mapping[action]()
  File "/home/userX/django_src/django/core/management.py", line 535, in diffsettings
    for key in sorted(user_settings):
NameError: global name 'sorted' is not defined

comment:6 by hugo, 18 years ago

Hmm. sounds like some python2.4-ism

by pb@…, 18 years ago

Attachment: diffsettings2.patch added

Python 2.3 compatible version

comment:7 by pb@…, 18 years ago

Hugo's correct, sorry about that. Uploaded a fix (and made the imports a one-liner).

Also, it's note that django.conf.init changes the INSTALLED_APPS tuple to a list -- that's bound to confuse someone. Maybe add a note to the docstring?

comment:8 by Adrian Holovaty, 18 years ago

Resolution: fixed
Status: reopenedclosed

(In [2674]) magic-removal: Fixed #1549 -- Removed Python 2.4ism introduced in [2671]

Note: See TracTickets for help on using tickets.
Back to Top