Opened 20 years ago
Closed 20 years ago
#1549 closed enhancement (fixed)
[patch] django-admin.py diffsettings: display differences between project settings and default settings
| Reported by: | 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)
Change History (10)
by , 20 years ago
| Attachment: | diffsettings.patch added |
|---|
comment:2 by , 20 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:4 by , 20 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:5 by , 20 years ago
| Resolution: | fixed |
|---|---|
| Status: | closed → reopened |
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:7 by , 20 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 , 20 years ago
| Resolution: | → fixed |
|---|---|
| Status: | reopened → closed |
patch to core/management.py