Open simonw opened 1 month ago
Tried this just now:
>>> import json
>>> from django.conf import settings
>>> print(json.dumps(settings.__dict__, indent=2, default=repr))
{
"_wrapped": "<Settings \"helloworld.settings\">",
"INSTALLED_APPS": [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"djp"
],
"DEBUG": true,
"LOGGING_CONFIG": "logging.config.dictConfig",
"LOGGING": {},
"DEFAULT_EXCEPTION_REPORTER": "django.views.debug.ExceptionReporter",
"FORCE_SCRIPT_NAME": null,
"DEFAULT_TABLESPACE": "",
"DEFAULT_AUTO_FIELD": "django.db.models.BigAutoField",
"ABSOLUTE_URL_OVERRIDES": {},
"AUTH_USER_MODEL": "auth.User",
"DATABASES": {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": "PosixPath('/private/tmp/helloworld/db.sqlite3')",
"ATOMIC_REQUESTS": false,
"AUTOCOMMIT": true,
"CONN_MAX_AGE": 0,
"CONN_HEALTH_CHECKS": false,
"OPTIONS": {},
"TIME_ZONE": null,
"USER": "",
"PASSWORD": "",
"HOST": "",
"PORT": "",
"TEST": {
"CHARSET": null,
"COLLATION": null,
"MIGRATE": true,
"MIRROR": null,
"NAME": null
}
}
},
"USE_I18N": true,
"LANGUAGE_CODE": "en-us",
"LOCALE_PATHS": [],
"DEFAULT_INDEX_TABLESPACE": ""
}
But showing the differences would be much more interesting.
This could be a command such as
./manage.py show_settings_diff
(or similar) - it could work by having thedjp.settings(globals())
function grab a snapshot of the current state before, then make the changes and stash a representation of that diff elsewhere.